How to remove ^M characters from a zip file?

Hi All,

As all of us know that while moving a file from Windows to Unix some unwanted ^M characters appear in the file. For my case I have release package in zip format which looks like Module_Name_Tag.zip. It contains some directory structure...like

Module_Name_Tag.zip
|
|--trunk/
|--config/
|--testing/

These all directories have some files within them. The problem is when the ZIP file is build in windows and deployed to the server in Unix environment. Automatically, ^M characters comes into all files.
I can execute

dos2unix

or some perl command like

perl -pi -e 'tr/\cM//d;'  <filename>

to remove them but it has to be done repeatedly on all files. As a matter of fact,
I have to 1. Unzip the package 2. Remove characters of all files 3. Zip it again. This looks cumbersome.

Is there any way to remove these characters directly from all files inside the zip?? or I have to conventionally write a script that will unzip , remove and zip the package again?? if it is there any intelligent idea how to proceed? Thanks in advance.

Regards,
Bhaskar

Well if you can't dos2unix on Windows before building the ZIP file, the next best thing is, as you have already identified, unzipping, translating and zipping up again on the UNIX side.

By the way,

tr -d \\r < filename

is a simpler alternative to your perl command.

Hi Cambridge,

Many thanks.