摘要: shell编程中常用的循环:while 和 for,在使用的过程中,会发现一些差别。1. 代码 1 #!/bin/bash 2 3 # while loop 4 echo -en "\t";date 5 cat abc.txt|while read user ip 6 do 7 { 8 ssh -oConnectTimeout=10 $user@$ip "hostname" < /dev/null 9 sleep 10s10 } &11 done12 wait13 echo "This is while loop."14 阅读全文
posted @ 2013-09-08 10:25 trdcaz 阅读(782) 评论(4) 推荐(0)
摘要: Linux中shell脚本编程,通常涉及到调用,下面列出几种调用的区别1. fork方式 创建sub-shell,在sub-shell中执行命令,执行完成返回父shell(sub-shell环境变量不影响父shell,默认方式) 通常,我们执行 sh ./test.sh 或者 ./test.sh 就是这种方式。2. source方式 在当前shell中执行 source 或者 .(小数点) 命令,执行完成接着执行当前shell命令3. exec方式 在当前shell中执行 exec 命令,执行完成直接退出,当前shell后面的命令不执行点击http://blog.csdn.net/zhuyi. 阅读全文
posted @ 2013-09-07 15:05 trdcaz 阅读(369) 评论(2) 推荐(0)