Linux Shell基础 - 流程控制 - for循环
Posted Fallen Lunatic
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux Shell基础 - 流程控制 - for循环相关的知识,希望对你有一定的参考价值。
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
以上是关于Linux Shell基础 - 流程控制 - for循环的主要内容,如果未能解决你的问题,请参考以下文章