Operating System - HP-UX
1753596 Members
6321 Online
108796 Solutions
New Discussion юеВ

Re: CRLF conversion help needed

 
SOLVED
Go to solution
Gary Hines
Advisor

CRLF conversion help needed

Hi,
I need a little help trying to convert CRLF. However, it's not the normal end-of-line conversion. I need to convert CRLF into a space. Any ideas on how I can go about doing this?
I've tried:
cat testfile | sed s/\\015\\012/ /g > tempfile
but that doesn't seem to do it.
3 REPLIES 3
Steven E. Protter
Exalted Contributor

Re: CRLF conversion help needed

Shalom,

First, try dos2unix

This sometimes does the trick.

Also, can you provide a file sample so we can look at it in hex and provide you a simple, scripted or perl based solution.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
James R. Ferguson
Acclaimed Contributor
Solution

Re: CRLF conversion help needed

Hi Gary:

# perl -pe 's%\r\n% %' file

...or if you want to update in-place, preserving a copy of 'file' as 'file.old':

# perl -pi.old -e 's%\r\n% %' file

Regards!

...JRF...
Gary Hines
Advisor

Re: CRLF conversion help needed

Perfect James! Just what I needed. Thanks very much!