Removing CTRL-M’s from all files in a directory.
Change to the directory where the files reside.
In this example I want to change all the .sql files.

ls *.sql | while read file
do
sed 's/^M//g' $file > ${file}.new
mv ${file}.new ${file}
done

Note : I used the keys “CTRL-V” then “CTRL-M” in the sed command above.