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

Pages: 1 2 3 4 5 6

Tags:

2 Responses to “Unix Tech Tips”

  1. Andrew Hardej Says:

    This will also do it.

    tr -d ‘15′ new_file_name

  2. Andrew Hardej Says:

    My prior post has the wrong syntax. See below:

    Removing ^M from UNIX text files

    tr -d ‘15′ new_file_name

Leave a Reply

Comments will be published after approval by Moderator.