Remove carriage returns in a text file

S. Krishnan skrishnan-R6A+fiHC8nRWk0Htik3J/w at public.gmane.org
Wed Feb 21 04:45:33 UTC 2007


On Mon, 2007-02-19 at 21:04 -0500, JoeHill wrote:
> I have a text file that was apparently saved on a Windows box using Notepad or
> somesuch, because it is replete with carriage returns (^M), which only appear
> when I open the file with Nano.

Pipe it through tr(1) invoked as something like tr -d '\015', which will
delete the CRs.  If you want to convert the carriage returns to line
feeds you can try tr '\015' '\012'.

HTH.
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list