Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can´t remove some wierd character ^M

Status
Not open for further replies.

kartapacio

Technical User
Sep 26, 2003
6
ES
Hi everybody,
I´m afraid this is something very stupid, but is driving me mad!!

I cant find a way to remove a ^M mark. That mark is^M present at the end of the line like this one^M
^M
^M (this i get if the line is empty)
I can see it only when I edit the file with vi (if i do a 'more' of the file, i cant see it.)

I guess is some sort of trailing character (The file´s source is a printing of a cobol program).

How can i remove that mark and leave it with the usual ^ for beguinnig and $ for end? (i`ve tried several sed commands but can´t find the way of doing it)

Any help would be very appreciated, thank´s in advance



 
Something like this ?
awk '{gsub(/\r/,"");print}' /path/to/input > output

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi PHV,

It worked perfectly !!! You make it look so easy, specially for newbies like me.

Thanks!!
 

Also you could use the dos2unix command.




----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
Or also:

cat infile|tr -d '\r' >outfile


----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
IIRC, you can do it in vi like this:
:1,$s/ctrl-Vctrl-M//

where ctrl- means press the control key.
I gave up vi for Emacs years ago, but typed that one often enough that I think I still remember it. (Vi users out there, feel free to correct me if my memory is failing.) :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top