One of the joys of working in both the *nix and Windows worlds is that from time to time I get a text file in DOS format i.e. with a CR/LF in each line instead of just an LF. This means I get a Ctrl-M (^M) character at the end of each line and if it is supposed to be an executable script it will give some very strange errors.
There are a number of utilities on various Unix variants to convert these file and they are called things like dtox, dos2unix but on my Kubuntu system it took a bit of tracking down.
The package is called tofrodos so
sudo apt-get install tofrodos
will install the utilities for you. The utilities are called fromdos and todos and do exactly what they say on the tin.
One thing I like about these variants is they work on a file “in situ” so rather than having to do something like
dos2unix file1.txt > file2.txt
is all you need.