---
title: "Linux Shell将逗号分隔的字符串转成换行"
author: "ChinaEstone"
date: "2016-08-19T15:23:07Z"
tags: []
categories: ["开源软件"]
slug: "linux-shell"
draft: false
lastmod: "2016-08-19T15:23:07Z"
id: 2319014
url: "https://chinaestone.iteye.com/blog/2319014"
---

```
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