Find it

Sunday, December 20, 2009

Removing ^M from unix text files

Removing ^M from unix text files

Using Perl :

Following command will change the orginal file itself so keep a backup copy .

perl -pi -e "s:^V^M::g"

You won't see the Control V on typing but it is needed to generate control

character ^M.

Using sed :

# sed -e `s/^V^M//g` existing_file_name > new_file_name

Using vi :

Open file in vi and enter the following at : prompt in command mode .


BTW There's also a utility dos2unix and unix2dos that you can use to convert characters to and fro DOS and UNIX.

1 comment: