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//gThis 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.