2

Let us assume I have a zip file called patch.zip, when I run unzip -l patch.zip I get the following output.

bin/a
bin/b
lib/c

To this zip file I want to add a new file, "Readme.txt" located at /path/to/Readme.txt in such a way that, when I re-run unzip -l patch.zip again I get something like this

bin/a
bin/b
lib/c
doc/Readme.txt

Any help would be appreciated.

0

I don't think there's a way to specify the pathname files should have within the zip-file, so you can't say "store /var/tmp/Readme.txt" as doc/Readme.txt".

You would have to create the directory layout on disk first, as a sort of staging area:

mkdir doc
cp -p /path/to/Readme.txt doc
zip foo.zip doc/Readme.txt
0
0

I just recreate the zip file. I know it might not be the solution you need, but it is a very simple solution. I've also found issues with messing with zip file contents while still compressed so found this method to be more reliable.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.