for循环语法及for循环脚本例子
在shell里for循环常用于执行有限次数的循环,而while一般才用于守护进程无限循环等等
语法:
i:变量名
words:变量取值范围
command:命令
for i in words; do #commanddone
现学现用,我们用for循环简单写一个显示当前目录下的文件脚本:
words=`ls /root/`for i in words; do echo $idone[root@node1]# sh test.sh anaconda-ks.cfgbootime.svggit_testmonitornull
完成!
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。