Removing ^M Characters

You’re here because you have something like the above in your text files, and it’s driving you towards violence.

The universe sent you here so I can help you. You’re welcome.

The prescribed fix is this:

sed -e 's/^M//'

If that worked you wouldn’t be here. The actual fix is this:

tr -d '\r'

Bonus on this one: it actually works!

Now fix your file and go get some air.

NotesFrom Vim you can do the following as an ex command to get the same result within a file: :%!tr -d '\r'
 •  0 comments  •  flag
Share on Twitter
Published on April 22, 2022 19:03
No comments have been added yet.


Daniel Miessler's Blog

Daniel Miessler
Daniel Miessler isn't a Goodreads Author (yet), but they do have a blog, so here are some recent posts imported from their feed.
Follow Daniel Miessler's blog with rss.