如何将每个字段扩展到文件中的一行(可能使用 awk 或 cut?)

How to spread each field to a line in a file (with awk or cut, maybe?)

我有一个格式如下的文件:

'word', 'word', 'word'
'word', 'word', 'word'
'word', 'word', 'word', 'word', 'word'
'word'

如何拆分 , 处的行并打印以下内容:

'word'
'word'
'word'
'word'
...

(注:OS X Yosemite)

您可以使用 tr 将 ',' 替换为 '\n'

cat somefile | tr ',' '\n'

尝试用新行替换 ,

 sed 's/, /\n/g' file