shell的数组操作
生活随笔
收集整理的這篇文章主要介紹了
shell的数组操作
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
#/bin/bash#創建數組方式1
arr[0]=hello
arr[1]=world#創建數組方式2
arr=(hello world)#創建數組方式3
arr=([1]=hello [2]=world)#遍歷數組方式1
for i in ${arr[*]}
doecho $i
done#獲得數組長度
length=${#arr[@]}
echo $length#遍歷數組方式2
i=1
while [ $i -lt $length ]
doecho $iecho ${arr[i]}i=`expr $[$i+1]`
done
bash是更高級的sh(支持數組)
更多參考資料
http://bbs.chinaunix.net/thread-1779167-1-1.html
轉載于:https://www.cnblogs.com/code-style/p/3183765.html
總結
以上是生活随笔為你收集整理的shell的数组操作的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: The following module
- 下一篇: iOS基础面试题