shell 数组循环的用法,对于一些构建工具很有帮助
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
array=('a' 'b' 'c' 'd' 'e')
arrayIndex[0]=1 arrayIndex[1]=2 arrayIndex[2]=3 arrayIndex[3]=4 arrayIndex[4]=5
array[0]='f' arrayIndex[1]=6
echo ${#arrayIndex[@]}
for var in ${arrayIndex[@]} do echo $var done
i=0 while [[ i -lt ${#arrayIndex[@]} ]];do echo ${arrayIndex[i]} let i++ done
|
使用shell做服务器的健康检查脚本
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
check_urls=( 'https://wiki.enbrands.com/display/IMX/hello' 'https://wiki.enbrands.com/display/IMX/hello' )
for url in ${check_urls[@]} do curl url done
|