Linux Shell基础 - 流程控制 - for循环 - while 循环 - until循环
生活随笔
收集整理的這篇文章主要介紹了
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
?
轉載于:https://www.cnblogs.com/patriot/p/7905437.html
總結
以上是生活随笔為你收集整理的Linux Shell基础 - 流程控制 - for循环 - while 循环 - until循环的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Alpha第十天
- 下一篇: 【转】c# [Serializable]