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
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
暂无评论。
评论功能维护中,当前仅展示历史评论。