Unix Tech Tips

2. 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” existing_file_name

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 .

:%s/^V^M//g

Share

Pages: 1 2 3 4 5 6

Leave a Reply

Your email address will not be published. Required fields are marked *