This script will remove the ^M generally found in windows modified/created files. It will remove all the ^M instances in one file. It can be run in any directory on your system.
1) Go to your scripts directory.
cd /usr/gbsd/
2) Create a file named dos2unix-^m.gbsdx
vi dos2unix-^m.gbsdx
3) Paste the following code*:
#!/bin/sh
cat $1 | tr -d "^M" > dos2unix-temp.erase.me
mv dos2unix-temp.erase.me $1
echo done
exit
* The ^M you see is not the characters ^ and M, but rather a character obtained by typing ctrl + v, + m (press and hold ctrl, then pres and let go v then m). This will give you ^M in the vi editor.
4) Save the file and quit.
:wq
5) Set the script to executable:
chmod 755 dos2unix-^m.gbsdx
6) In your bourne shell file, add this alias:
vi ~/.cshrc
alias dos2unix sh /gbsd/dos2unix-^m.gbsdx
* You might have to login again to be able to use the new alias!
7) Find a file that has ^M in it. From console type:
dos2unix filename-to-clean
The program will return 'done' when finished.
You can also use the script like this by placing the file you want to clean in the same directory:
./dos2unix-^m.gbsdx file-to-clean
You can download the script here: http://ghettobsd.org/gbsd-scripts/dos2unix-%5em.gbsdx