ITeye博客

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

ChinaEstone · 2016-08-19 15:23 · Linux学习资料 · Linux Tips · 开源软件 · Markdown

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

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。