Linux Shell编程(2): for while
for (( i = 0; i < 5; i++)) do echo "current number is $i" done SERVICES="80 22 25 110 8000 23 20 21 3306 " for x in $SERVICES do echo $x done for x in a b c do echo $x done for i in $* #$*是字符串:以"参数1 参数2 ... " 形式保存所有参数 do echo "parameter is $i" done for i in *.sh do echo $i done for i in $(ls *.sh) do echo $i done array=(a1 a2 a3) #array=([0]=a1 [1]=a2 [2]=a3) #array[0]=a1 array[1]=a2 array[2]=a3 echo "the length of array is ${#array[@]}" for item in ${array[@]} do echo "item in array: "$item done for i in /Users/scg/PycharmProjects/xiaoliang/main/*.py do echo $i done
i=5 while [ $i -ge 0 ] do echo $i if [ $i -eq 2 ] then break fi i=$[i-1] done