unzip Extract files from a zip archive
Opens .zip archives: it can list what is inside, test that the file is intact, and extract it. By default it unpacks into the current directory, so choose a destination with -d. Use zip to create archives.
Synopsis
unzip [-l | -t] archive.zip
unzip [OPTION]... archive.zip [file ...] [-x file ...] [-d directory]
Common options
| Option or form | What it does |
|---|---|
-l | List the files in the archive (names, sizes and dates) without extracting |
-d directory | Extract into this directory, creating it if needed, instead of the current directory |
-t | Test the archive for errors without extracting |
-n | Never overwrite existing files. Skip them without asking |
-o | Overwrite existing files without asking. Dangerous, use with care |
-q | Quiet: print less. Use -qq for even less |
-j | Junk paths: put every file in one folder, ignoring the folders stored in the archive |
-x list | Extract everything except the files that follow. Place it after the file list |
Examples
zip -rq docs.zip docs && unzip -l docs.zip
zip -rq docs.zip docs && unzip -q docs.zip -d restore && ls restore
docs
zip -rq docs.zip docs && unzip -tq docs.zip
zip -rq docs.zip docs && unzip -q docs.zip docs/readme.md -d out && ls out/docs
readme.md
zip -rq docs.zip docs && unzip -p docs.zip docs/readme.md
zip -rq docs.zip docs && unzip -q docs.zip -x 'docs/old/*' -d out && ls -R out
Notes
- unzip extracts into the current directory by default. A zip file with many items at the top level can scatter files all over a folder. Check it with unzip -l, or extract into a new folder with -d.
- If a file already exists, unzip asks whether to overwrite it, which stops a script. Use -n to skip existing files or -o to overwrite them. -o replaces files with no confirmation.
- Always quote patterns for files and -x, such as 'docs/old/*', so unzip matches them inside the archive rather than the shell matching them on disk.
- -P password lets you give a password on the command line, but other users can see it in the process list. Leave it out and unzip will ask you for it.
- unzip handles only zip files. For .tar.gz or .tgz archives, use tar. On macOS, tar can also read zip files, but unzip is the clearer choice.
See also
Last reviewed 2026-10-07.