Tuesday, 3 July 2012

Getting rid of ^M characters in any unix file



It’s always one single command which resolves most of the critical issues!!!!!

Issue:  A file on the UNIX server contains multiple ^M characters in it.

Solution:

Edit the file using vi editor and save it.

In vi:

%s/<Ctrl-v><Ctril-M>//g

Save the file (!wq)

1 comment:

  1. Other Two Better options, which will work on all Unix Flavours

    Using col command:
    cat filename | col -b > newfilename

    Using sed command:
    sed 's/^M//g' filename > newfilename

    Thanks
    ~M.A. (old Friend)

    ReplyDelete