script for removing ^M Character

May 31, 2011 at 02:10:49
Specs: Windows XP
Hi , i have one pearl script to generate configuration file . One its generated, the output file come with ^M character in all the EOL. CAn anyone know shell script to remove the ^M . i know how to do in the one by one file. But I need to do the same thing for all the files in the particular folder. Please help me on this.....


See More: script for removing ^M Character

Report •

May 31, 2011 at 05:56:51
anybody please give me the solution???

Report •

May 31, 2011 at 10:14:05
I am assuming you are looking for a unix script? First, I would use the dos2unix command.

If that is not available, this link describes several ways of deleting control-M's:

Place anyone of them into a for loop. Here is an example:



cd <to_your_directory>
for file in *.txt
   tr -d '\015\032' < $file > $file.tmp
   cp $file.tmp   $file 
# end script

If you want to do every file in the directory simply drop the .txt extension above. Once the script works the way you want, change the copy command, cp, to move, mv.

Report •

June 1, 2011 at 00:27:46
Hi nails,
Thanks for your reply. But i have already tried this one. I need to remove the ^M character tin the main perl script itself.

I dono how to add this particular functionality in my main perl script. Could you please assist on this...?


Report •

Related Solutions

June 1, 2011 at 06:41:50
Isn't a perl script just another file? You should be able to paste my command into a different script and do the conversion.

I don't have any idea what your problem is.

Report •

Ask Question