read命令主要用于从标准输入读取内容或从文件中

2019-09-28 作者:小鱼儿玄机30码   |   浏览(60)

实例拓扑图:

何以设置非管理员用     户配置特定的IIS站点

1. 加多TCP/IP端口,用于增加打字与印刷机使用,文件名: add_port.reg

基本用法

    read命令主要用于从正规输入读取内容或从文件中读取内容,并把消息保存到变量中。其常用用法如下所示:

read [选项] [文件]
选项 解释
-a array 将内容读取到数值中,变量默认为数组且以空格做为分割符
-d delimiter 遇到指定的字符即停止读取
-n nchars 指定最多可以读入的字符数,即定义输入文本的长度
-r 屏蔽转义符
-p prompt 显示提示信息
-s 静默模式,在输入字符时不在终端中显示,常用于密码输入等
-t timeout 指定超时时间
-u FD 从文件描述符中读入,该FD可以由exec开启

图片 1

一、           增加IIS管理服务

 1 Windows Registry Editor Version 5.00
 2 [HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlPrintMonitorsStandard TCP/IP PortPorts]
 3 "StatusUpdateInterval"=dword:0000000a
 4 "StatusUpdateEnabled"=dword:00000001
 5 [HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlPrintMonitorsStandard TCP/IP PortPortsIP_192.168.6.245]
 6 "Protocol"=dword:00000002
 7 "Version"=dword:00000002
 8 "HostName"="192.168.6.245"
 9 "IPAddress"=""
10 "HWAddress"=""
11 "PortNumber"=dword:00000203
12 "SNMP Community"="public"
13 "SNMP Enabled"=dword:00000001
14 "SNMP Index"=dword:00000001
15 "PortMonMibPortIndex"=dword:00000001
16 "Queue"="print"
17 "Double Spool"=dword:00000000
18 [HKEY_LOCAL_MACHINESYSTEMControlSet001ControlPrintMonitorsStandard TCP/IP PortPorts]
19 "StatusUpdateInterval"=dword:0000000a
20 "StatusUpdateEnabled"=dword:00000001
21 [HKEY_LOCAL_MACHINESYSTEMControlSet001ControlPrintMonitorsStandard TCP/IP PortPortsIP_192.168.6.245]
22 "Protocol"=dword:00000002
23 "Version"=dword:00000002
24 "HostName"="192.168.6.245"
25 "IPAddress"=""
26 "HWAddress"=""
27 "PortNumber"=dword:00000203
28 "SNMP Community"="public"
29 "SNMP Enabled"=dword:00000001
30 "SNMP Index"=dword:00000001
31 "PortMonMibPortIndex"=dword:00000001
32 "Queue"="print"
33 "Double Spool"=dword:00000000

用法示例

1、从标准输入读入

[root@localhost test]# cat read.sh
#!/bin/bash
echo -n "Please input your name:"
read name
echo "Hello $name"
[root@localhost test]# bash read.sh
Please input your name:Jack
Hello Jack

2、钦赐展现音讯从专门的职业输入读入

[root@localhost test]# cat read.sh
#!/bin/bash
# echo -n "Please input your name:"
read -p "Please input your name:" name
# read name
echo "Hello $name"
[root@localhost test]# bash read.sh
Please input your name:Jack
Hello Jack

在上述示例中,read是三遍还行多个参数的,如下所示:

read -p "Please input your name:" firstName secondName lastName

但须要专一的事项如下:

  • 一旦输入的数量少于变量个数,则多余的变量不会博获得数量,即变量值为空
  • 如若输入的多少多于变量个数,则出乎的多寡将总体赋给最终一个变量
  • 倘诺在read命令前面未有概念任何变量,脚本在举行时,如若顾客输入数据,此时数码则保留到景况变量$REPLY

3、钦点超时时间

[root@localhost test]# cat read.sh
#!/bin/bash
if read -t 3 -p "Please input your name:" firstName secondName lastName
then
  echo "variable is $firstName - $secondName - $lastName"
else
   echo -e  "ntimeoutn"
fi
[root@localhost test]# bash read.sh
Please input your name:
timeout

4、从钦赐文件中读取内容

[root@localhost test]# cat -n test.txt
     1  this is test text.
     2  this is second line.
     3  Hello world
     4  C# Main
     5  Python
# 使用-u选项
[root@localhost test]# cat readtest.sh
#!/bin/bash
exec 5< ~/test/test.txt
count=0
while read -u 5 var
do
 let count=$count 1
 echo "Line $count is $var"
done
echo "Total line count is $count"
exec 5<&-
[root@localhost test]# bash readtest.sh
Line 1 is this is test text.
Line 2 is this is second line.
Line 3 is Hello world
Line 4 is C# Main
Line 5 is Python
Total line count is 5
# 使用管道
[root@localhost test]# cat readtest.sh
#!/bin/bash
count=1
cat ~/test/test.txt |  while read line
do
 echo "Current line $count - $line "
 let count=$count 1
done
echo "Total line count is $count"
[root@localhost test]# bash readtest.sh
Current line 1 - this is test text.
Current line 2 - this is second line.
Current line 3 - Hello world
Current line 4 - C# Main
Current line 5 - Python
Total line count is 1
# 使用重定向
[root@localhost test]# cat readtest.sh
#!/bin/bash
count=0
while read line
do
 let count=$count 1
 echo "Current line $count - $line "
done < ~/test/test.txt
echo "Total line count is $count"
[root@localhost test]# bash readtest.sh
Current line 1 - this is test text.
Current line 2 - this is second line.
Current line 3 - Hello world
Current line 4 - C# Main
Current line 5 - Python
Total line count is 5

正文同步在微信订阅号上揭穿,如各位小友大家欣赏小编的稿子,也足以关注自身的微信订阅号:woaitest,或扫描上边包车型客车二维码增加关怀:
图片 2

D本田CR-V1和D福睿斯2铺排keepalived和lvs作主从架构或主主架构,EnclaveS1和WranglerS2安顿nginx搭建web站点。

 图片 3

 说明:只须求修改(5, 8,21,24, )行里面的IP地址,那个IP地址是互连网打印机的IP地址,打字与印刷机要设置成静态IP地址。

只顾:各节点的年华须求共同(ntpdate ntp1.aliyun.com);关闭firewalld(systemctl stop firewalld.service,systemctl disable firewalld.service),设置selinux为permissive(setenforce 0);同时确定保证各网卡帮衬MULTICAST(多播)通讯。

二、           开发银行政管理战胜务

 

因而命令ifconfig能够查看见是还是不是开启了MULTICAST:

 图片 4

2.  增多打字与印刷机,文件名: add_printer.bat

本文由小鱼儿玄机30码发布于小鱼儿玄机30码,转载请注明出处:read命令主要用于从标准输入读取内容或从文件中

关键词: 小鱼儿玄机30码