remove ^M characters from file using sed

前端 未结 9 2373
情书的邮戳
情书的邮戳 2020-12-01 15:35

I have this line inside a file:

ULNET-PA,client_sgcib,broker_keplersecurities
,KEPLER

I try to get rid of that ^M (carriage return) charact

9条回答
  •  暖寄归人
    2020-12-01 16:26

    If Perl is an option:

    perl -i -pe 's/\r\n$/\n/g' file

    -i makes a .bak version of the input file
    \r = carriage return
    \n = linefeed
    $ = end of line
    s/foo/bar/g = globally substitute "foo" with "bar"

提交回复
热议问题