Wednesday, June 16, 2021

Remove CTRL-M characters from a file in UNIX

 We can remove ^M by below methods

1st Method - Using sed command

Type below command: 
 
sed -e "s/^M//" filename > newfilename
 
Note :- To enter ^M, type CTRL-V, then CTRL-M. 

2nd Method -  Using vi Editor

Open the file in vi editor

 

vi filename

Inside vi [in ESC mode] type below command- 

:%s/^M//g
 

then [Press Enter Key ]

Note :- To enter ^M, type CTRL-V, then CTRL-M. 

then save the file by below command

:wq


No comments:

Post a Comment

Remove CTRL-M characters from a file in UNIX

 We can remove ^M by below methods 1st Method - Using sed command Type below command:    sed -e "s/^M//" filename > newfilena...