remove ^M in a file

i have a file that was ftp'd and has ^M characters at the end,its a big file and i want some commands that can help me remove it.

In vi,

:s/^M//g

for ^M, type ctrl+v+m

sed 's/^M$//'

Sed is almost the same and you also need to type ctrl+v and ctrl+m or it won't work.

you can use

dos2unix srcfilename tgtfilename

u can use this

tr -d '\015' <filename>

you can use dos2unix command also.

Check the man pages for more details.

dos2unix filename.sh

thanks it all worked

To prevent the problem use the "ascii" command in ftp. The default is "binary" which will copy MSDOS style text file record terminators (carriage-return line-feed) when of course the correct unix text file terminator is just line-feed.