removing ^M from a csv file

前端 未结 3 1862
我寻月下人不归
我寻月下人不归 2021-01-05 02:06

I have a problem when I try to remove ^M from a csv

When I type vim or vi file.csv, I get

A, TK,2015-04-06,14.4^M,14.7,10.0,0.0,54.0^M,13.3^M,135.0^M         


        
3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-05 02:29

    You can try:

    perl -pE 's/(\^M|\r)//g' < file >file2
    

    should remove

    • the literal ^M - sequence of two characters ^ and M
    • and the ^M as \r character.

提交回复
热议问题