unix

How do I replace ^M characters in my file with a newline?

Have you ever come across a file on a Unix/Linux server that looks like this?

This is a line of my file^Mand this should be the next line

To update the file, you can use vi.

vi $my_file
Type :s!^M!\r!g

where ^M is Control-Caret then Control-M.

Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *

To Top