Operating System - HP-UX
1822001 Members
3920 Online
109639 Solutions
New Discussion юеВ

How to remove ^M from large Unix text file globally?

 
vz7r1x
Regular Advisor

How to remove ^M from large Unix text file globally?

I have a large Unix depot file that ended up with ^M at the end of the each text line. There are ^M in other places in the fil but I want to remove only those at the end of the line.

Can you help? Thanks
5 REPLIES 5
Dennis Handly
Acclaimed Contributor

Re: How to remove ^M from large Unix text file globally?

You can use dos2ux(1) to remove them on the end.

Why do you have them embedded too?

You can also use vi:
:%s/^vCR$//

Where that is control-V then a CR.
vz7r1x
Regular Advisor

Re: How to remove ^M from large Unix text file globally?

1, $ s/^v^m//g

you hold control key and type v m, you will see ^M getting typed only.
Dennis Handly
Acclaimed Contributor

Re: How to remove ^M from large Unix text file globally?

>1,$s/^v^m//g

Your "g" on the end will change the embedded ^Ms too. You need that "$" anchor.
vz7r1x
Regular Advisor

Re: How to remove ^M from large Unix text file globally?


Thanks for fast response. I thought that I was the only one replying to the question and closed the thread.
I did not mean to be uncourteous to you.
Hein van den Heuvel
Honored Contributor

Re: How to remove ^M from large Unix text file globally?

dear vz7r1x,


You could hit the 're-open this threat' button, assign a few points to acknoledge the effort and solution. Hit 'submit' for those points, and then re-close.


Regards,
Hein
[0 points for this please]