Aix remove ^M

Hi,
On AIX
in vi , I run :
:%s/^M//g

I receive :

ex: 0602-071 No match exists for the substitute pattern.

What is wrong?
Thanks.

@big123456, if you are ok with running command on terminal and saving output into Input_file then please try following once.

tr -d '\r' < Input_file > temp && mv temp Input_file

This will remove control M characters from Input_file and save Input_file without control M characters.

Thanks,
R. Singh

Thanks.
But:
tr -d '\r' < Input_file > temp && mv temp Input_file
I receive:
Usage: tr [ -c | -cds | -cs | -ds | -s ] [-A] String1 String2
tr { -cd | -cs | -d | -s } [-A] String1

Regards.

With perl:

perl -i.orig -pe 's,\cM,,g' file
2 Likes

I would be very surprised if that is the actual command that you typed. In the usage string (2nd line) you can see that the command is correct. Are you using bash shell?

--
Returning to your original post: You need to enter ^M as CTRL-V followed by CTRL-M

2 Likes

@balajesuri, Thanks Bala for posting nice answer and Good to see you back on forums :b:
We definitely hope to see more from you, cheers :slight_smile:

Thanks,
R. Singh

1 Like

Thanks.
This is what I ran:

tr -d '\r' myfile.txt temp && mv temp myfile.txt

Regards.

You need to include the < and > signs. Those are significant

1 Like

Yes. It worked:

 tr -d '\r' < myfile.txt > temp && mv temp myfile.txt

Thank you.

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.