本文原创 欢迎转载 Cy158358.cublog.cn #!/bin/sh echo "test for while" #初始化终端 tput init #保存当前光标位置 tput sc i=0 #在新行首输出0%到100% while [ $i -lt 101 ] do tput rc echo -n $i% i=`expr $i + 1` usleep 10000 done echo "" 将上面的代码保存为脚本文件while,然后执行./while,将在单独的一行首输出0%~100%: [root@localhost while]# ./while test for while 100% 本文来自ChinaUnix博客,如果查...
by Cy158358 - Linux文档专区 - 2011-07-30 17:51:02 阅读(2674) 回复(1)
版本为suse的10.2[code]reportdb:~/wang # cat /etc/SuSE-release SUSE linux Enterprise Server 10 (x86_64) VERSION = 10 PATCHLEVEL = 2[/code]shell为bash 代码如下:[code]#!/bin/bash echo "test"|while read var;do export a=$var echo "while-a:$a" done echo "a:$a"[/code]执行后[code]reportdb:~/wang # ./while.sh while-a:test a:[/code]为什么变量a在while循环结束后,a变量的值就被释放了?
#!/bin/sh echo "test for while" #初始化终端 tput init #保存当前光标位置 tput sc i=0 #在新行首输出0%到100% while [ $i -lt 101 ] do tput rc echo -n $i% i=`expr $i + 1` usleep 10000 done echo "" 将上面的代码保存为脚本文件while,然后执行./while,将在单独的一行首输出0%~100%: [root@localhost while]# ./while test for while 100%
#!/bin/sh
while read LINE
linux程式设计-11.shell Script(bash)--(10)控制圈while/until while list do list done 当list为True时,该圈会不停地执行。 例一 : 无限回圈写法 #!/bin/sh while : ; do echo "do something forever here" sleep 5 done 例二 : 强迫把pppd杀掉。 #!/bin/sh while [ -f /var/run/ppp0.pid ] ; do killall pppd done --------------------------------------------------------------------...
本帖最后由 归隐乡村 于 2014-08-30 18:31 编辑 Timeout while executing a shell scrip zabbix 邮件报警提error里面显示上述语句。已经更改server端的timeout为30秒,命令行测试mail速度还可以。没有思路,求思路。顺便说下,我是完全按照这个帖子来的。 http://www.cnblogs.com/lehao/p/3946710.html 。究竟哪里有问题,该怎么追踪呢。
源代码: #!/bin/sh DIR="/jing/" IP="127.0.0.1" while read ADDRESS do wget -t 3 "http://""${ADDRESS}""${DIR}""20071025.txt" done < "/var/www/html/jing/ip_list.txt" 提示错误: ': not a valid identifierta.sh: line 4: read: ` 请问是什么原因?
function waithadoop() { while [1-eq1] do reduceNum=`hd -ls $1 | wc -l` if [ ${reduceNum} -ne $2 ] ; then sleep 1; else break; fi done } waithadoop path 50 写了这样一个shell程序,执行后报错 ./run.sh.bak: line 3: [1-eq1]: command not found 这个怎么改啊?
#!/bin/sh while read LINE do echo $LINE done < names.txt 问:循环执行的第一次,LINE值为多少? 文件names.txt的第一行数据? 求问为什么
我用shell写了一个脚本,需要用到while循环执行一些命令。 但有时候这些命令会出错,不再执行下去,我现在先要设置一个超时时间,使得出错超时后可以继续执行下一个循环, 请问我需要怎么实现它?
是这样,目前有一个shell脚本中有一个while循环,里面设置有一个变量A实现累加结果的作用 我想要在循环外面取最后的A的值,应该怎么做?请教高手 --------------------------------------------------- echo "a b c"|while read i do echo $i sum+=$i done echo =======$sum=========== ---------------------------------...