I have a problem with some scripts and I know I can;t be unique. Maybe some of you with more programming experiance then I have can help we with this. I don't think it needs much...

I have a piece of code that strips and cleans the Ctl-M windows end of line charactors out of documents on my unix servers. Problem is this only works for one file at a time and I have to execute the command like


remove-m.pl file1 >> file2


mv file2 file1

as you can see this can get long and tedious when there are many files and if your prone to fetching files straight to unix the way I am its even more of
ahassle to DL them to win just so you can ascii transfer them and they come over clean.

When I want to do is take the the bit of code I have and modify it so it will just clean the files. I don't know if I have to write tempory files and then copy
them over the origionals or not but if thats what I have to do so be it.. I figure all that shoudl be needed is a "for
each" loop to accomidate it..

I usally just use the command and create files that
are named like this:


and then mv the clean files to overwrite the origionals.

If I could get this tool to do a directory for me or even better, prompt me to do them recursivly It would admins like me HOURS.

Is this something someone here can help me with??

Here is the piece of code I have:

# Remove Control M's ^M
# Matt Wright ([email protected])
# Version 1.0
# Created on: 10/95 Last Modified on: 12/7/95

while (<>) {
$_ =~ s/\cM\n/\n/g;
print $_;

# To use this script, type:
# rm_cont_m.pl infile > outfile

# This script will remove those pesky control M's off
of the end of your
# scripts after you have edited them in DOS or

# The infile should be the name of the file you want
to remove control
# m's from and the outfile should be a different file
where you want to
# redirect the output to. Don't use the infile as the
outfile or it will
# remove your original file. :-(

# If you do not specify an outfile, then the script
will print the contents
# to the screen.

# Ths script has no error checking, and is very

Let me know what you think