Shell command to cut ^ M characters from a text file

Possible duplicate:
Delete carriage return on Unix

I am reading some data created by a third-party third party. I noticed that the ASCII text in the file alternates with ^ M characters, which I believe is 13 in ASCII and represents a carriage return without a line break.

Is there one liner that I can use to remove ^ M characters from a file?

I work on Linux (Ubuntu).

+6
source share
2 answers

You can use sed as follows:

sed -i.bak 's/^M$//' infile.txt 

To enter ^M , you need to enter CTRL-V and then CTRL-M .

+12
source

OR

  dos2unix infile.txt file2.txt .... 

OR

 man dos2unix 

for more details.

Ihth

+7
source

All Articles