例如有一段字符串:
bak1_list="a,b,c,d"
可以进行分隔:
OLD_IFS="$IFS"
IFS=","
arr=($bak1_list)
IFS="$OLD_IFS"
for val in ${arr[@]}
do
echo "$val"
done
输出:
a
b
c
d
例如有一段字符串:
bak1_list="a,b,c,d"
可以进行分隔:
OLD_IFS="$IFS"
IFS=","
arr=($bak1_list)
IFS="$OLD_IFS"
for val in ${arr[@]}
do
echo "$val"
done
输出:
a
b
c
d
本文标题:[Shell]将字符串分隔进shell数组
本文链接:https://www.haomeiwen.com/subject/qssyvftx.html
网友评论