[Shell]将字符串分隔进shell数组

例如有一段字符串:

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数组)