Updating a File in a Zip Archive


 
Thread Tools Search this Thread
Operating Systems AIX Updating a File in a Zip Archive
# 1  
Old 09-27-2006
Updating a File in a Zip Archive

Hello everyone,

I have a script that pulls a text file out of a zip archive and updates the file. What I need to do is put it back in the zip archive and replace the old one, but I am having no luck.

Everything I search on forums or internet points to the command zip, that command is not available to me. Also this needs to be a zip archive that can be extracted using the unzip command.

Any help would be great.

Thanks,

DBridle
# 2  
Old 09-27-2006
Using InfoZip on Solaris 2.8, the -f (freshen) flag works like this:

Code:
$ unzip -Z archive.zip  
Archive:  archive.zip   918 bytes   4 files
-r--r--r--  2.2 unx     152 tx defN 27-Sep-06 14:15 file1
-r--r--r--  2.2 unx     152 tx defN 27-Sep-06 14:15 file2
-r--r--r--  2.2 unx     152 tx defN 27-Sep-06 14:15 file3
-r--r--r--  2.2 unx     152 tx defN 27-Sep-06 14:15 file4
4 files, 608 bytes uncompressed, 416 bytes compressed:  31.6%
$ /usr/ucb/lptest > file3
$ zip -f archive.zip file3
freshening: file3 (deflated 97%)
$ unzip -Z archive.zip    
Archive:  archive.zip   1255 bytes   4 files
-r--r--r--  2.2 unx     152 tx defN 27-Sep-06 14:15 file1
-r--r--r--  2.2 unx     152 tx defN 27-Sep-06 14:15 file2
-r--r--r--  2.2 unx   16000 tx defN 27-Sep-06 14:27 file3
-r--r--r--  2.2 unx     152 tx defN 27-Sep-06 14:15 file4
4 files, 16456 bytes uncompressed, 753 bytes compressed:  95.4%

# 3  
Old 09-27-2006
Unfortunately the zip command from InfoZip is not available to me.
# 4  
Old 09-27-2006
I'm sorry, obviously I did not read carefully enough. Let me try again...You stated that you have a script that extracts a file from a ZIP archive. What command are you using to do this? Also, what OS are you using? I'd be very surprised if a UNIX zip package had an unzip command but no zip counterpart. I'd also be surprised if any zip package wasn't just InfoZip compiled for that OS.

Try running your unzip command with only a -v or -V for version information.
# 5  
Old 09-27-2006
UnZip 5.40 of 28 November 1998, by Info-ZIP.

There is no zip counterpart to it that I can see. Please bare in mind that I work for a large financial corporation, so everything is fairly restrictive ;(
# 6  
Old 09-27-2006
Unfortunately, unzip is "out-going" only. Unlike its gzip cousin which uses the same executable for gzip, gunzip, and gzcat, Info-ZIP's zip command is an entirely different binary. So, without installing the zip command -- available from http://www.info-zip.org/Zip.html -- there is no way for you to freshen files in a ZIP archive.

I appreciate the nature of a restrictive environment, but if your management requires you to update ZIP archives, then they must allow you to use the necessary tools. That's always a fun sell.

Good luck.

Just for giggles, try scanning the system (this could take a while):

$ find / -local -type f -name zip
# 7  
Old 09-27-2006
My unix admin group was being champs and installed zip, with the -f refresh option so I'm all set.

Thank you for your help in pointing me in the right direction!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How can we Zip multiple files created on the same date into one single zip file.?

Hi all i am very new to shell scripting and need some help from you to learn 1)i have some log files that gets generated on daily basis example: i have abc_2017_01_30_1.log ,2017_01_30_2.log like wise so i want to zip this 4 logs which are created on same date into one zip folder. 2)Post zipping... (1 Reply)
Discussion started by: b.saipriyanka
1 Replies

2. UNIX for Beginners Questions & Answers

How can we Zip multiple files created on the same date into one single zip file.?

Hi all i am very new to shell scripting and need some help from you to learn 1)i have some log files that gets generated on daily basis example: i have abc_2017_01_30_1.log ,2017_01_30_2.log like wise so i want to zip this 4 logs which are created on same date into one zip folder. 2)Post zipping... (2 Replies)
Discussion started by: b.saipriyanka
2 Replies

3. Shell Programming and Scripting

Zip Multiple files to One .zip file in AIX system

Hi I have a requirement in unix shell where I need to zip multiple files on server to one single .zip file. I dont see zip command in AIX and gzip command not doing completely what I want. One I do .zip file, I should be able to unzip in my local Computer. Here is example what I want... (9 Replies)
Discussion started by: RAMA PULI
9 Replies

4. Shell Programming and Scripting

Zip a list of specific files to an archive

Hi all, i've got the following problem: We've got a shell-script, that creates some different files based on several criteria given, using a sql-script. After creating, those files are individually zipped and stored, then sent to a ftp-server. This is all working since 2010, but now they have... (3 Replies)
Discussion started by: Biggreuda
3 Replies

5. Shell Programming and Scripting

questions about updating a zip file

hi all, I have millions of zip files about 200M each, and i'm trying to add a couple of small files(jpg txt etc.) into these zip files, less than 100k. when i'm doing this, is it gonna unzip all 200M large files, add files and re zip again? or just add new small ones in? i'm concerned... (3 Replies)
Discussion started by: sunnydanniel
3 Replies

6. AIX

ZIP multiple files and also specify size of zip file

I have to zip many pdf files and the size of zip file must not exceed 200 MB. When size is more than 200 MB then multiple zip files needs to be created. How we can achieve this in UNIX? I have tried ZIP utility but it takes a lot of time when we add individual pdfs by looping through a... (1 Reply)
Discussion started by: tom007
1 Replies

7. Shell Programming and Scripting

how to remove absolute paths from zip archive

Hi, I need to write an bash script which works like it can copy files from remote machine through ssh to the server where script is running in zip format with the structure i want. I don't want to get absolute path in zip archive. Please let me know how it can be possible. ssh... (4 Replies)
Discussion started by: mirfan
4 Replies

8. Shell Programming and Scripting

Read specific file from a zip archive without extracting

Hi All, I would like to extract specific file from a zip archive. I have a zip archive "sample.zip". sample.zip contains few text files and images... text1.txt, text2.txt, pic.jpg etc... I need to read specific file "text2.txt" from "sample.zip" WITHOUT EXTRACTING the zip file. ... (4 Replies)
Discussion started by: sridharg
4 Replies

9. Shell Programming and Scripting

awk updating one file with another, comparing, updating

Hello, I read and search through this wonderful forum and tried different approaches but it seems I lack some knowledge and neurones ^^ Here is what I'm trying to achieve : file1: test filea 3495; test fileb 4578; test filec 7689; test filey 9978; test filez 12300; file2: test filea... (11 Replies)
Discussion started by: mecano
11 Replies

10. UNIX for Dummies Questions & Answers

unzip .zip file and list the files included in the .zip archive

Hello, I am trying to return the name of the resulting file from a .zip archive file using unix unzip command. unzip c07212007.cef7081.zip Archive: c07212007.cef7081.zip SecureZIP for z/OS by PKWARE inflating: CEP/CEM7080/PPVBILL/PASS/G0063V00 I used the following command to unzip in... (5 Replies)
Discussion started by: oracledev
5 Replies
Login or Register to Ask a Question