This script will remove the ^M generally found in windows modified/created files. It will remove all the ^M instances in all the files in the working directory.
1) In your scripts directory (/usr/gbsd in our examples) create a file named m-clean-all.gbsdx
cd /usr/gbsd/
vi m-clean-all.gbsdx
2) paste the following:
#!/bin/sh
ls > zerase
query=$1
for i in `cat zerase`; do
sh /gbsd/dos2unix-^m.gbsdx $i
rm zerase
done
3) Change the file permissions of the new file so you can execute it:
chmod 750 m-clean-all.gbsdx
4) Add the following alias to your .cshrc under the alias section:
vi ~/.cshrc
alias m-clean-all sh /usr/gbsd/m-clean-all.gbsdx
5) Change to the directory with the files containing ^M. Run the program to clean up all of your files:
m-clean-all
All done!
You might have to login again for the alias to take effect.
In order for this to work you must have dos2unix-^m.gbsdx in your /usr/gbsd/ directory found here: http://ghettobsd.org/new-and-improved/foro/topic/remove-the-m-from-1-file-in-console
If you have it in a different directory, you can change the code to reflect that.
You can download the script here: http://ghettobsd.org/gbsd-scripts/m-clean-all.gbsdx