unzip
Extract files from a ZIP archive
TLDR
Extract all files/directories from specific archives into the current directory
Extract files/directories from archives to a specific path
Extract files/directories from archives to stdout alongside the extracted file names
Extract an archive created on Windows, containing files with non-ASCII (e.g. Chinese or Japanese characters) filenames
List the contents of a specific archive without extracting them
Extract a specific file from an archive
SYNOPSIS
unzip [options] file[.zip] [file(s) ...] [-x exclude_file(s)] [-d exdir]
PARAMETERS
-l
List archive contents without extracting.
-t
Test archive integrity (check checksums) without extracting.
-v
Verbose listing or extraction, showing more details.
-z
Print only the archive comment.
-p
Pipe files to standard output (stdout) without creating them on disk.
-q
Quiet mode; suppress most output messages.
-o
Overwrite existing files without prompting.
-n
Never overwrite existing files.
-u
Update existing files; overwrite if the archive file is newer, create if not existing.
-f
Freshen existing files; overwrite if the archive file is newer, but do not create new files.
-d exdir
Extract files into the specified directory exdir.
-x file(s)
Exclude specified files from extraction.
-j
Junk paths; flatten the directory structure, placing all extracted files directly into the destination directory.
-a
Auto-convert text files (CR/LF to LF, etc.) from Windows/DOS to Unix format.
DESCRIPTION
unzip is a utility program for decompressing and extracting files from ZIP archives. It is widely used on Unix, Linux, and other systems as the standard tool for handling .zip files, which are a common format for distributing compressed data.
The command can list the contents of a ZIP archive, test the integrity of the archived files, or extract specific files or all files from an archive. It supports a variety of compression methods and features found in ZIP archives, including basic password protection.
Developed as part of the Info-ZIP project, unzip provides compatibility with files created by PKZIP and other commercial and open-source ZIP programs.
CAVEATS
While unzip supports basic password-protected archives, it may not handle more complex encryption methods like AES encryption used by some modern ZIP tools. For such cases, 7z or other specialized tools might be required.
Also, unzip might not always perfectly preserve all Unix-specific file permissions, ownership, or symbolic links, especially when extracting across different file systems or when the original archive was created on a different OS.
EXIT STATUS
unzip returns an exit status of 0 if successful. Any non-zero exit status indicates an error or a warning, which is crucial for scripting. For example, 1 for one or more warning errors, 2 for a generic error, 9 for a bad command line, and so on. Refer to the man page for a complete list.
WILDCARDS AND PATTERNS
When specifying files to extract or exclude, unzip supports shell-style wildcards such as * (matches any sequence of characters) and ? (matches any single character). These patterns allow for flexible selection or exclusion of multiple files based on their names. Quoting patterns is often necessary to prevent the shell from expanding them before unzip can process them.
HISTORY
The unzip utility is a core component of the Info-ZIP project, which began in the late 1980s and early 1990s. The goal was to provide an open-source, portable set of tools fully compatible with the PKZIP file format, which was a de facto standard for data compression and archiving on DOS/Windows systems. unzip quickly became the ubiquitous tool for handling ZIP archives across Unix-like operating systems due to its robust implementation and adherence to the ZIP specification.