How to remove ^M characters from a zip file?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to remove ^M characters from a zip file?
# 1  
Old 06-25-2009
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
Code:
dos2unix

or some perl command like
Code:
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
# 2  
Old 06-25-2009
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,
Code:
tr -d \\r < filename

is a simpler alternative to your perl command.
# 3  
Old 06-25-2009
Hi Cambridge,

Many thanks.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove non printing characters from file

How do I remove the printer escape sequence, the first 5 characters, that occurs on every 33rd line in a file, see hex dump of line 1. 0000 1e 00 00 00 00 0a 0a 0a 20 0a 20 20 20 20 20 20 .... 0010 20 20 20 20 20 20 20 20 20 20 0a 42 49 4c 4c 20 Thanks, (2 Replies)
Discussion started by: jgt
2 Replies

2. Shell Programming and Scripting

I want to remove 1st and last two characters of each line of the file

I want to remove 1st and last two characters of each line of the file Ex: file1 zzfile1ee @xfile2:y qfile3>> @ file4yy and redirect to the file called new Basically file will have any charcter including space, spical character... Please help.... (7 Replies)
Discussion started by: shell1509
7 Replies

3. Shell Programming and Scripting

Remove characters from the file

i know , the below question has been repeated. can you guys guide me . I have the below input 999999 xxxxxxxxxxxxxx 123.45 2013-05-02 08:14 1 1 1 xxxx 999999 xxxxxxxxxxxxxx 123.45 2013-06-02 02:14 1 4 1 dddd i need to remove from the column 54 to 70 , as like the below output.... (9 Replies)
Discussion started by: expert
9 Replies

4. UNIX for Advanced & Expert Users

What my puzzle file!, How to remove special characters ??

My application generate file but it have special characters in these file. I would like to clear special characters by vi editor and not use cat /dev/null > to_file I try to remove characters manually, but I'm can not! root@MyHost /tmp> ls -l puzzle.txt -rw-r--r-- 1 root system ... (5 Replies)
Discussion started by: arm_naja
5 Replies

5. UNIX Desktop Questions & Answers

Remove new line characters from a file

I tried using below command tr -cd "" < InputFile.xml > output.txt ============= This removes all the tabs/newline/extra spaces from a file it successfully removed all the extra spaces,tabs and new line characters but then the complete file become one record. I want to retain one new line... (1 Reply)
Discussion started by: saini
1 Replies

6. Shell Programming and Scripting

Remove invalid database characters on a file

Hi All - I'm building a script wherein it is design to remove characters that are not accepted on a non-unicode database. Examples are the following: ï,¿,½,Â,é, etc. I can easily sed those characters one-by-one but I there's a problem when other unicode characters are found. Is there any way to... (1 Reply)
Discussion started by: Jin_
1 Replies

7. Shell Programming and Scripting

Remove the characters from the file

Hi, I have one file in the following format. exa_resu_adj.4ge v.47645 PERSONAL INFORMAIONS PVT LTD 31 Dec 2009 04:36 Page 1 SALARY REPORT Account Account Name CCode Bill No Balance T Amt ----------- ------------ ------- ---------- ------------- ------------- 17490001 Mr Ram PM 10... (6 Replies)
Discussion started by: Kattoor
6 Replies

8. Shell Programming and Scripting

Trying to remove '^M' characters from a file.

Hi guys, Hope you are all well. This is a line of data from a csv file. I have used vi and set the 'set list' option to display the trailing $ character. "01","Grocery","01006","eat Fish & Spreads"$ I have tried the following commands, but neither of them appear to be working? 1) tr... (13 Replies)
Discussion started by: Krispy
13 Replies

9. Shell Programming and Scripting

Remove characters from file name

Here is my code. for file in *1.3.html ; do mv "$file" `echo $file | tr '.1.3' ''` ; done For some reason I am getting an error. mv: file.idlesince.1.3.html and file.idlesince.1.3.html are identical Could this be done a different way? (5 Replies)
Discussion started by: mrlayance
5 Replies

10. UNIX for Dummies Questions & Answers

How to remove null characters from file?

I'm trying to remove the null characters from a file and copy it to std output. I'm using emacs and I create the following one line bash file (followed by the error messages): sed -e 's/^@//' <ConfigItemReplicator.install.log /usr/bin/bash: -c: line 0: unexpected EOF while looking for... (1 Reply)
Discussion started by: siegfried
1 Replies
Login or Register to Ask a Question