1819504 Members
3208 Online
109603 Solutions
New Discussion юеВ

Remove ^M Character

 
SOLVED
Go to solution
Karthick K S
Frequent Advisor

Remove ^M Character

Hi,

How to remove ^M Character from a file.
8 REPLIES 8
Ranjith_5
Honored Contributor
Arunvijai_4
Honored Contributor
Solution

Re: Remove ^M Character

# sed 's(ctrl v ctrl m)g//g' old.file > new.file

In vi do the following:

:g/^M/s///

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Yogeeraj_1
Honored Contributor

Re: Remove ^M Character

also:
dos2ux file1 file2 > file1
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Ranjith_5
Honored Contributor

Re: Remove ^M Character

in vi,

:%s/\^M//g


Regards,
Syam
Adisuria Wangsadinata_1
Honored Contributor

Re: Remove ^M Character

Hi,

There are 3 solutions (possibly more)

1. within vi, type the following:

:1,$s/^V^M//

Note that the key sequence is CTRL+V and CTRL+M, only the "^M"
will appear on screen.


2. Use the tr command:

tr -d \\015 < filename > newfilename


3. Use the dos2ux utility:

dos2ux filename > newfilename

Hope this information can help you.

Cheers,
AW
now working, next not working ... that's unix
Senthil Prabu.S_1
Trusted Contributor

Re: Remove ^M Character

GETTING RID OF ^M

To get rid of ^M
in text files .

tr -d '^M' outputfile

But to get this
'^M' in the command
line:

Keep CTRL pressed
and then press v and m

--
Prabu.S
One man's "magic" is another man's engineering. "Supernatural" is a null word.
Senthil Prabu.S_1
Trusted Contributor

Re: Remove ^M Character

Also, one can use "string" utility that comes with unix.

STRING STRIPPING

Remove all ^M and other control
characters from file ABC

strings ABC > ABC-good


--
Prabu.S
One man's "magic" is another man's engineering. "Supernatural" is a null word.
Karthick K S
Frequent Advisor

Re: Remove ^M Character

Thanks to all for given a solution