标签:[1] 数组 shel done bash str class lov nbsp
#!/bin/bash tmp="test,girl,boy,love"
OLD_IFS="$IFS" IFS=","
arr=($a) IFS="$OLD_IFS"
echo "arr[0] is: ${arr[0]}"
echo "arr len: ${#arr[@]}"
for s in ${arr[@]}
do
echo "$s"
done
存储老的分隔符 OLD_IFS="$IFS" 设置分隔符 IFS=","
按着分隔符IFS自动分隔
arr=($a)
分隔后的全部数组
${arr[@]}
分隔后的每一项
${arr[0]} ${arr[1]} ...
分割后的数组长度
${#arr[@]}
存储整个索引值
${!arr[@]}
标签:[1] 数组 shel done bash str class lov nbsp
原文地址:https://www.cnblogs.com/faithfu/p/9542486.html