Operating System - HP-UX
1830899 Members
2782 Online
110017 Solutions
New Discussion

how to remove \r show by od -c ?

 
SOLVED
Go to solution
Phuc Nguyen_1
Advisor

how to remove \r show by od -c ?

Hi,
I need to remove (or substitue with empty space) the the following from a file:
1. where \r occurs
2. where \n \n occurs

\r (carriage return character) and \n \n (new-line character) revealed when run 'od -c'

I tried sed 's/\r//' filea > fileb, but does not work because these are non-printable characters. How do I tell sed to remove these non-printable characters?

Thank you.
1 REPLY 1
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: how to remove \r show by od -c ?

It sounds as though you are trying to deal with CRLF to LF termination on data that comes from a PC.
You may be able to simply use the dos2ux command like this:
dos2ux < oldile > newfile. Man dos2ux for details.

If you want to simply remove the CR's then this should work:

tr -d '\015' < oldfile >newfile
If it ain't broke, I can fix that.