What is the simplest way to remove all the carriage returns \\r
from a file in Unix?
sed -i s/\r//
or somesuch; see man sed
or the wealth of information available on the web regarding use of sed
.
One thing to point out is the precise meaning of "carriage return" in the above; if you truly mean the single control character "carriage return", then the pattern above is correct. If you meant, more generally, CRLF (carriage return and a line feed, which is how line feeds are implemented under Windows), then you probably want to replace \r\n
instead. Bare line feeds (newline) in Linux/Unix are \n
.