dbaspot
Tags Register FAQ Calendar Search Today's Posts Mark Forums Read

How to replace ^M with a Hard Return with "sed"? - shell

This is a discussion on How to replace ^M with a Hard Return with "sed"? - shell ; + Jolly Roger : > In article , > Michael Vilain wrote: > >> cat filename | tr "\r" "\n" > newfilename > > BTW, you can do it without the cat and pipe [...] In the (good?) old days ...


Home > Database Forum > Operating Systems > shell > How to replace ^M with a Hard Return with "sed"?

Reply

 

LinkBack Thread Tools Display Modes
  #11  
Old 11-13-2008, 04:36 PM
Database Bot
 
Join Date: Sep 2009
Posts: 1,236,254
Database Administrator is on a distinguished road
Default Re: How to replace ^M with a Hard Return with "sed"?

+ Jolly Roger :

> In article ,
> Michael Vilain wrote:
>
>> cat filename | tr "\r" "\n" > newfilename

>
> BTW, you can do it without the cat and pipe [...]


In the (good?) old days that used to earn an immediate "useless use of
the cat award" on comp.unix.shell. Have they stopped handing those out?

--
* Harald Hanche-Olsen
- It is undesirable to believe a proposition
when there is no ground whatsoever for supposing it is true.
-- Bertrand Russell
Reply With Quote
  #12  
Old 11-13-2008, 08:42 PM
Database Bot
 
Join Date: Sep 2009
Posts: 1,236,254
Database Administrator is on a distinguished road
Default Re: How to replace ^M with a Hard Return with "sed"?

Vladimir Usenko writes:

>> It's there.

> I was saying that "I dunno about it" because I not have access and
> not working with MacOS... (I don't clean all newsgroup before sending
> answer).


I didn't know the newsgroup was dirty!
Reply With Quote
  #13  
Old 11-14-2008, 10:55 PM
Database Bot
 
Join Date: Sep 2009
Posts: 1,236,254
Database Administrator is on a distinguished road
Default Re: How to replace ^M with a Hard Return with "sed"?

Michael Vilain wrote:
> You want to replace the carriage return character (ASCII CONTROL-M or
> \015) with a new-line (ASCII CONTROL-J or \010). sed doesn't really
> handle control characters very will but there's a UNIX shell command
> that works better for this (tr--translate characters). So use this
> instead:
>
> cat filename | tr "\r" "\n" > newfilename


If you don't want to mess with a newfilename

perl -p -i -e 's:\r:\n:g;' filename


--
Wes Groleau
Heroes, Heritage, and History
http://UniGen.us/PGV
Reply With Quote
Reply

Thread Tools
Display Modes



All times are GMT -4. The time now is 09:29 AM.