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