in reply to How to remove "^M" in the files ?

There are many ways to remove it -

In vi:
:%s/^V^M//g


Or, run dos2unix:
dos2unix dosfile.txt unixfile.txt