Remove ^M (Control-M) characters from a file in Unix

When checking my /etc/multipath.conf file, there was a lot of hidden characters ^M at the end of lines

root@linux:~ # cat -vet /etc/multipath.conf

To remove them, use tr and redirect the output to a new file.

root@linux:~ # tr -d ‘\015’ < /tmp/multipath.conf

Check the file and if everything is okay, replace the original file

root@linux:~ # tr -d ‘\015’ < /tmp/multipath.conf > /tmp/
root@linux:~ # cat -vet /tmp/
root@linux:~ # mv /tmp/ /tmp/multipath.conf