700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > Linux Shell基础 - 流程控制 - for循环 - while 循环 - until循环

Linux Shell基础 - 流程控制 - for循环 - while 循环 - until循环

时间:2019-08-19 11:41:27

相关推荐

Linux Shell基础  -  流程控制 - for循环 - while 循环 -  until循环

01、for循环

语法一:

for time in m n a e => 以空格区分for循环个数

do

echo "This time is $time"

done

语法二:

s=0

for (( i=1;i<=100;i=i+1 ))

do

s=$(( $s+$i ))

done

echo "The sum of 1+2+....+100 is : $s"

例子:批量解压缩脚本

cd /lamp

ls *.tar.gz>ls.log

for i in $(car ls.log)

do

tar -zxf $i &>/frv/null

done

rm -rf /lamp/ls.log

02、while循环

while [ 条件判断式 ]

do

程序

done

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。