#!/bin/bash
a="one,two,three,four"
#要将$a分割开,可以这样:
OLD_IFS="$IFS"
IFS=","
arr=($a)
IFS="$OLD_IFS"
for s in ${arr[@]}
do
echo "$s"
done
#!/bin/bash
a="one,two,three,four"
#要将$a分割开,可以这样:
OLD_IFS="$IFS"
IFS=","
arr=($a)
IFS="$OLD_IFS"
for s in ${arr[@]}
do
echo "$s"
done
本文标题:shell 将字符串分割成数组
本文链接:https://www.haomeiwen.com/subject/dsjqbftx.html
网友评论