Linux Shell将逗号分隔的字符串转成换行

OLD_IFS="$IFS"
IFS=","
arr=(`cat a.txt`)
IFS="$OLD_IFS"
for s in ${arr[@]}
do
 echo $s | tr -d '"'
done

将逗号分隔的字符串放到 a.txt文件,中格式:ss,21,ss,

输出格式:

ss

21

xx

猜你喜欢

转载自chinaestone.iteye.com/blog/2319014