Cheat Sheet #day64 - unzip

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.zipExtract files to a specific directory:
unzip archive.zip -d /path/to/destination/Overwrite existing files without prompting:
unzip -o archive.zipNever overwrite existing files:
unzip -n archive.zipSuppress all output except errors:
unzip -q archive.zipExtract files without their directory structure:
unzip -j archive.zipList contents of the ZIP file:
unzip -l archive.zipExclude specific files while extracting:
unzip archive.zip -x "*.bak"Extract a file to standard output:
unzip -p archive.zip file.txt > extracted.txtTest the integrity of the ZIP file:
unzip -t archive.zip
Additional Information
Help option:
unzip --helpView
unzipmanual 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.




