Remove carriage return in Unix

后端 未结 21 2260
傲寒
傲寒 2020-11-22 03:40

What is the simplest way to remove all the carriage returns \\r from a file in Unix?

21条回答
  •  忘了有多久
    2020-11-22 04:04

    If you are a Vi user, you may open the file and remove the carriage return with:

    :%s/\r//g
    

    or with

    :1,$ s/^M//
    

    Note that you should type ^M by pressing ctrl-v and then ctrl-m.

提交回复
热议问题