Replace comma with newline in sed on MacOS?

后端 未结 13 2050
借酒劲吻你
借酒劲吻你 2020-11-27 09:27

I have a file of id\'s that are comma separated. I\'m trying to replace the commas with a new line. I\'ve tried:

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

b

13条回答
  •  猫巷女王i
    2020-11-27 10:27

    Apparently \r is the key!

    $ sed 's/, /\r/g' file3.txt > file4.txt
    

    Transformed this:

    ABFS, AIRM, AMED, BOSC, CALI, ECPG, FRGI, GERN, GTIV, HSON, IQNT, JRCC, LTRE,
    MACK, MIDD, NKTR, NPSP, PME, PTIX, REFR, RSOL, UBNT, UPI, YONG, ZEUS
    

    To this:

    ABFS
    AIRM
    AMED
    BOSC
    CALI
    ECPG
    FRGI
    GERN
    GTIV
    HSON
    IQNT
    JRCC
    LTRE
    MACK
    MIDD
    NKTR
    NPSP
    PME
    PTIX
    REFR
    RSOL
    UBNT
    UPI
    YONG
    ZEUS
    

提交回复
热议问题