I have a file named 'sourceZip.zip'
This file ('sourceZip.zip'
) contains two files:
'textFile.txt'
'binFile.bin'
I also have a file named 'targetZip.zip'
This file ('targetZip.zip'
) contains one file:
'jpgFile.jpg'
In linux, what bash command shall I use to copy both files ('textFile.txt'
, 'binFile.bin'
) from the source archive ('sourceZip.zip'
) straight into the second archive ('targetZip.zip'
), so that at the end of the process, the second archive ('targetZip.zip'
) will include all three files?
(ideally, this would be done in one command, using 'zip' or 'unzip')
Best Answer
Using the usual command-line
zip
tool, I don't think you can avoid separate extraction and update commands.There are other languages with more convenient zip file manipulation libraries. For example, Perl with Archive::Zip. Error checking omitted.
Another way is to mount the zip files as directories. Mounting either of the zip files is enough, you can use
zip
orunzip
on the other side. Avfs provides read-only support for many archive formats.Fuse-zip provides read-write access to zip archives, so you can copy the files with
cp
.Warning: I typed these scripts directly in my browser. Use at your own risk.