How Would I Write This Vim Command for `Sed`?
I Have A. Csv with Special Characters That Are Wrecking an Import I Need to Do. in Vim, I Discovered Away to Remove the Special Characters with: :%S/\R//G This...
I have a .csv with special characters that are wrecking an import I need to do.
In VIM, I discovered away to remove the special characters with :
:%s/\r//g
This removes ^M from some of my broken lines.
But I'd like to either write this into a bash script, or into my ruby script. So I was curious if there's a way I can perform this special character search and replace in either Bash or Ruby.
Searching for ^M does not work. And also you wouldn't see this character in any text editor except for VIM.
1 Answer
This works for me (Fedora 20, GNU sed 4.2.2):
sed -e 's/\r$//' <file-in> > <file-out>
(Replace <file-in> and <file-out> with your file names.) I use file to check the line endings.