Questions tagged [zip]

For questions about ZIP files and associated tools. ZIP is a file format used for data compression and archiving.

ZIP files are archive files, containing other files which can optionally be compressed and/or encrypted. The ZIP format is very popular, dating back to PKZIP in 1989, supported by tools available on most if not all platforms. It is also used as the format for a number of other file types, including JAR files (as used in the Java world) and OpenDocument files (as used by LibreOffice and OpenOffice).

On Unix and Linux platforms, ZIP files are handled by Info-ZIP and many other tools, including file managers such as Midnight Commander and Nautilus (GNOME Files). The format is supported by a number of libraries, including libzip.

551 questions
282
votes
8 answers

Extract only a specific file from a zipped archive to a given directory

I need to extract a single file from a ZIP file which I know the path to. Is there a command like the following: unzip -d . myarchive.zip path/to/zipped/file.txt Unfortunately, the above command extracts and recreates the entire path to the file at…
Naftuli Kay
  • 39,676
116
votes
7 answers

How to extract only a specific folder from a zipped archive to a given directory?

How does one extract a specific folder from a zipped archive to a given directory? I tried using unzip "/path/to/archive.zip" "in/archive/folder/" -d "/path/to/unzip/to" but that only creates the folder on the path I want it to unzip to and does…
56
votes
7 answers

Extra-bytes error when unzipping a file

When I enter unzip ../founation-latest.zip, it outputs this: warning [../foundation-latest.zip]: 248 extra bytes at beginning or within zipfile (attempting to process anyway) The file is 138KB. It unzips correctly, but why am I getting this…
53
votes
3 answers

Test integrity of ZIP file?

Near as I can tell the zip -T option only determines if files can be extracted -- it doesn't really test the archive for internal integrity. For example, I deliberately corrupted the local (not central directory) CRC for a file, and zip didn't care…
53
votes
5 answers

Error trying to unzip file: "need PK compat. v6.1 (can do v4.6)"

I received a zip file from a bank. I get the following error when I trying to unzip it. unzip filename.zip Archive: filename.zip skipping: SOME_STUFF.pdf need PK compat. v6.1 (can do v4.6) The file command returns Zip archive data for this…
Faheem Mitha
  • 35,108
48
votes
5 answers

"zip warning: name not matched" while compressing a directory

I have a folder of around 180 GBs, I need to zip it like: zip -p password /Volumes/GGZ/faster/mybigfolder/* /Volumes/Storage\ 4/archive.zip But it says: zip warning: name not matched: /Volumes/Storage 4/archive.zip So how do I do this? On…
DisplayName
  • 11,688
37
votes
1 answer

The zip format's external file attribute

This is a slightly exotic question, but there doesn't seem to be much information on the net about this. I just added an answer to a question about the zip format's external file attribute. As you can see from my answer, I conclude that only the…
Faheem Mitha
  • 35,108
33
votes
6 answers

Error when unzipping a file

I am getting the following error when unzipping a file unzip user_file_batch1.csv.zip Archive: user_file_batch1.csv End-of-central-directory signature not found. Either this file is not a zipfile, or it constitutes one disk of a multi-part…
26
votes
3 answers

Preserving permissions while zipping

How can I preserve permissions while compressing a folder using zip? I know how to preserve symlinks using --symlinks is there a similar option for permissions?
Binoy Babu
  • 1,035
23
votes
6 answers

Change working directory

I'm trying to compress a directory at /home/cyrus/sql And I wanted to change the working directory when zipping the folder: / $ zip -b /home/cyrus sql.zip /home/cyrus/sql But when I check the zip file: / $ unzip -l sql.zip Archive: sql.zip …
19
votes
1 answer

Zip a file without including the parent directory

I have a folder that contains multiple files folder artifact1.app artifact2.ext2 artifact3.ext3 ... My goal is to zip the file from outside this folder (so without using cd command) without including the folder dir. zip -r ./folder/artifact.zip…
Lorenzo B
  • 439
13
votes
1 answer

Why are directories sometimes listed explicitly in ZIP files?

While building an application that extracts ZIP files I noticed that sometimes ZIP files explicitly contain entries for the directories and sometimes not. Given for example the following structure folder1/ └── file1 I find files that give the…
12
votes
3 answers

If the maximum size of a ZIP archive is 4 GB then how can I have a 33 GB ZIP archive?

I have this: -rw-r--r-- 1 user user 36166999908 Jan 29 2022 tmp.archive.part1.zip -rw-r--r-- 1 user user 5579574562 Jan 29 2022 tmp.archive.part2.zip -rw-r--r-- 1 user user 5097536636 Jan 29 2022 tmp.archive.part3.zip -rw-r--r-- 1 user user…
11
votes
5 answers

How can I tell if "unzip" will create a single folder ahead of time?

A common scenario is having a zip file in a directory with other work: me@work ~/my_working_folder $ ls downloaded.zip workfile1 workfile2 workfile3 I want to unzip downloaded.zip, but I don't know if it will make a mess or if it nicely creates…
user1717828
  • 3,542
9
votes
3 answers

Add file to deep inside a zip file

Say I want to add the file file.txt to foo.zip, I could just do zip -u foo.zip file.txt. However inside the zip-file there already exist a folder with the path foo.zip/very/many/paths/ (relatively to the zip-file). How would I add file.txt to the…
Tyilo
  • 5,981
1
2 3 4 5 6