unzip
Command Cheatsheet
The unzip
command is used to extract files from a ZIP archive. It’s a commonly used utility for decompressing ZIP files in Unix-like systems. Here’s a quick reference guide:
Basic Syntax
unzip [OPTION]... ZIP_FILE
Common Options
-d DIR
,--directory=DIR
: Extract files to the specified directory.unzip archive.zip -d /path/to/destination/
-o
,--overwrite
: Overwrite existing files without prompting.unzip -o archive.zip
-n
,--never-overwrite
: Never overwrite existing files.unzip -n archive.zip
-q
,--quiet
: Suppress all output except errors.unzip -q archive.zip
-j
,--junk-paths
: Extract files without their directory structure.unzip -j archive.zip
-l
,--list
: List the contents of the ZIP file without extracting them.unzip -l archive.zip
-x FILE
,--exclude=FILE
: Exclude files matching the pattern.unzip archive.zip -x "*.bak"
-p
,--stdout
: Write files to standard output.unzip -p archive.zip file.txt > extracted.txt
-t
,--test
: Test the integrity of the ZIP file without extracting it.unzip -t archive.zip
Examples
Extract all files to the current directory:
unzip archive.zip
Extract files to a specific directory:
unzip archive.zip -d /path/to/destination/
Overwrite existing files without prompting:
unzip -o archive.zip
Never overwrite existing files:
unzip -n archive.zip
Suppress all output except errors:
unzip -q archive.zip
Extract files without their directory structure:
unzip -j archive.zip
List contents of the ZIP file:
unzip -l archive.zip
Exclude specific files while extracting:
unzip archive.zip -x "*.bak"
Extract a file to standard output:
unzip -p archive.zip file.txt > extracted.txt
Test the integrity of the ZIP file:
unzip -t archive.zip
Additional Information
Help option:
unzip --help
View
unzip
manual page:man unzip
This cheatsheet covers the essential options and usage scenarios for the unzip
command. For more detailed information, refer to the man
page or use unzip --help
.