shell脚本的read命令问题 #cat alarm.txt %a dsafa %A %a adsfjaljdfla %A #cat alarm.txt|grep "%A"|wc -l| read alarmNo #echo #{alarmNo} 为什么没有显示出来"2"? 急,在线等 必须使用命令行将"%A"的个数读入变量中。
by kenail2002 - Shell - 2005-09-10 20:25:28 阅读(4298) 回复(6)
read命令 功能: 从键盘输入内容赋给变量 格式: read [选项] [变量1] [变量2] [变量n] 选项: -p 提示输入内容 -t 等待输入内容秒数 本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/44606/showart_1385597.html
根据以下命令来判断WAS是否在运行状态,最后一行表明该服务是STARTED,我想要取到最后一行,请大家帮忙 [root@was root]# /opt/WebSphere/AppServer/bin/serverStatus.sh server1 ADMU0116I: 在文件 /opt/WebSphere/AppServer/logs/server1/serverStatus.log 中记录工具信息 ADMU0500I: 检索 server1 的服务状态 ADMU0508I: Application Server" server1" 是 STARTED /opt/WebSphere/AppServe...
可以使用r e a d语句从键盘或文件的某一行文本中读入信息,并将其赋给一个变量。如果只 指定了一个变量,那么r e a d将会把所有的输入赋给该变量,直至遇到第一个文件结束符或回 车。 它的一般形式为: read varible1 varible2 ... 在下面的例子中,只指定了一个变量,它将被赋予直至回车之前的所有内容: [root@localhost sgy]#read name shang [root@localhost sgy]#echo $name shang 如果输入文本域过长, shell 将所有的超长部...
本人SUN的服务器,SOLARIS 9系统,在shell中想用read命令从一个文本文件(/lianxi/abc)中读取其中的所有行,并将每行的3个文本段本别显示出来,但是我的程序只能循环显示第一行,为什么??因为read命令每次只能从文本中读取第一行,而无法自动读取下一行??附上我自己编的程序: while read c < /lianxi/abc do set $c echo "$1" echo "$2" echo "$3" done 后来我把程序改成: while read c < /lianxi/abc do set $c echo "$1...
这是在"man bash"中的一段 [code]read [-ers] [-u fd] [-t timeout] [-a aname] [-p prompt] [-n nchars] [-d delim] [name ...] One line is read from the standard input, or from the file descriptor fd supplied as an argument to the -u option, and the first word is assigned to the first name, the second word to the second name, and so on, with leftover words and their intervening separators ...
有些shell下,运行read命令后,用户可以使用回退键(BackSpace)删除错误输入的字符,如sh 而有些shell下,运行read命令,就不能使用回退键,bash好象就不行。 这个问题该如何解决啊?