~Onlooker 2013-04-02 07:48 采纳率: 33.3%
浏览 280
已采纳

用逗号分隔(perl / sed / awk)[ duplicate ]将多行转换为一行

This question already has an answer here:

I have the following data in multiple lines:

foo
bar
qux
zuu
sdf
sdfasdf

What I want to do is to convert them with one line and comma separated:

foo,bar,qux,zuu,sdf,sdfasdf

What's the best unix one-liner to do that?

</div>

转载于:https://stackoverflow.com/questions/15758814/turning-multiple-lines-into-one-line-with-comma-separated-perl-sed-awk

  • 写回答

8条回答 默认 最新

  • 关注

    Using paste command:

    paste -d, -s file
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(7条)

报告相同问题?