##### 迴圈 #####
有四種方式:while ... do ... done,until ... do ... done,for ... do ... done,for ... in ... do ... done
## while ... do ... done
while condition
do//do what you want
done
解釋:當condition不成立時終止迴圈
## until ... do ... done
until condition
do//do what you want
done
解釋:剛好和while 相反,當condition成立時終止迴圈
## for ... do ... done
for ((初始值; 條件; 執行步驟))
do//do what you want
done
解釋:例子說明問題,1到100的和 ~~
sum=0
for (( i=1; i<=100; i++
dosum=$(($sum+$i))
done
## for ... in ... do ... done
這個比較特別,第一次見到,哈
for var in con1 con2 con3 ...
do//do what you wan
done
解釋:執行第一次迴圈時,變數var的值是con1; 第二次時是con2,第三次是con3;...依此類推
for color in red yellow white
doecho "the color is $color"
done
shell script學習筆記2
bash中的變數都是無型別的,可以通過declare來宣告int型變數 0,1,2 9,如果引數超過9個,那就需要用 的方式 引數數目 引數集合 最後乙個引數 整數比較 eq,ne,gt,ge,lt,le,如 if a eq b 需要雙括號,如 a b 字串比較 a z 如果 a以 z 開頭,那麼將...
shell script學習筆記一
the fist line should be the following bin bash return value exit n usage of read command,讀鍵盤的輸入 read pt variable p 後面可以接提示資訊 t 後面可以接等待的秒數,這樣指令碼不用一直等下去...
Linux學習筆記(Shell Script)
vim showname.sh bin bash program user inputs his first name and last name.program shows his full name.history 2015 07 16 vbird first release path bin ...