Is it possible to copy a file into a zip archive?

14,403

Solution 1

Use -m to import a file to a ZIP archive.

I found this on StackOverflow maybe it helps you.
How to move a file in to zip uncompressed, with zip cmd tool

But be careful it deletes the source file after it adds it to the archive. See the link for more details.

UPDATE

Instructions from this site. http://linux.about.com/od/commands/l/blcmdl1_zip.htm.
-m moves the specified files into the ZIP archive; actually, this deletes the target directories/files after making the specified ZIP archive.

If a directory becomes empty after removal of the files, the directory is also removed. No deletions are done until zip has created the archive without errors. This is useful for conserving disk space, but is potentially dangerous so it is recommended to use it in combination with -T to test the archive before removing all input files.

zip -m yourfile zip.file

Solution 2

**for jar extension you can use jar command as the following :

jar -uf file.jar newFile

**OR you can extract file from jar extension as following :

jar -xf file.jar fileToBeExtract 

Have Fun :)

Share:
14,403

Related videos on Youtube

moata_u
Author by

moata_u

Updated on September 17, 2022

Comments

  • moata_u
    moata_u almost 2 years

    I want to copy a file into a ZIP or JAR archive.

    Is that possible? If so how?

  • moata_u
    moata_u over 13 years
    i tried cp -m q.txt archive.zip !!!**not working