How to Remove Ctrl M characters in files from directories and its subdirectories

Hi,
How to recursively remove Ctrl M characters in files from a directory and its sub directory ?

I know unix2dos command is there but to remove in bunch of files ... ?

Thanks

You need to write a script.

Try modifying with the following script............

for files in *.html;
do
mv $files $files.old
dos2unix $files.old $files
rm -rf $files.old
done

find /path/to/files -print | \
while read file
do
     dos2ux "$file" > ./tmpfile
     mv ./tmpfile "$file"
done

Hi corleone,

      Iam getting error

/could not open /dev/kbd to get keyboard typed ......

Do I need to save the script in .sh format ?
How do I run the script ? Kindly reply since Iam naive. Iam using unix on solaris.

Thanks

This error comes from dos2unix and doesn't stop the utility from working. You could simply redirect stderr

dos2unix filename > newfilename 2> /dev/null

A google seach provided these links:

Link 1
Link 2

skdp,

just ignore it..... :slight_smile: