Remove \r (CR) from CSV

后端 未结 3 2144
自闭症患者
自闭症患者 2020-12-11 09:17

On OSX I need to remove line-ending CR (\\r) characters (represented as ^M in the output from cat -v) from my CSV file:



        
3条回答
  •  青春惊慌失措
    2020-12-11 09:35

    Try the unix2dos command.

    Example: unix2dos infile outfile

    http://en.wikipedia.org/wiki/Unix2dos

    The wikipedia page has some examples using perl and sed too.

    perl -i -p -e 's/\n/\r\n/' file
    sed -i -e 's/$/\r/' file
    

提交回复
热议问题