- Unsupervised Learning
- Posts
- Removing ^M Characters
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.
Notes
From Vim you can do the following as an ex command to get the same result within a file: :%!tr -d '\r'