unzip: Comprehensive Guide to Extracting Zip Archives in Linux
Unlock the power of the unzip command in Linux with this comprehensive guide. Learn various extraction techniques, including extracting files to standard output, listing files, updating existing files, excluding specific files, extracting into a specific directory, and much more.
Extract files to standard output, no messages
unzip -p foo.zip
List files (short format)
unzip -l foo.zip
Freshen existing files, create none
unzip -f foo.zip
Test compressed archive data
unzip -t foo.zip
Update files, create if necessary
unzip -u foo.zip
Display archive comment only
unzip -z foo.zip
List verbosely/show version info
unzip -v foo.zip
Exclude files that follow (in xlist)
unzip foo.zip -x filename_to_exclude
Extract files into a specific directory
unzip foo.zip -d /path/to/directory
Never overwrite existing files
unzip -n foo.zip
Quiet mode
unzip -q foo.zip
Overwrite files WITHOUT prompting
unzip -o foo.zip
Junk paths (do not make directories)
unzip -j foo.zip
Match filenames case-insensitively
unzip -C foo.zip
Restore UID/GID info
unzip -X foo.zip
Keep setuid/setgid/tacky permissions
unzip -K foo.zip
Examples
Extract all files except 'joe' from zipfile 'data1.zip'
unzip data1 -x joe
Send contents of 'foo.zip' via pipe into program 'more'
unzip -p foo | more
Quietly replace existing 'ReadMe' if archive file newer
unzip -fo foo ReadMe
List files inside a zip archive
unzip -l foo.zip
Extract a specific file from a zip archive
unzip foo.zip filename_to_be_unzipped
Unzip a zip archive
unzip foo.zip
Unzip multiple zip files
for zip_file in ./*.zip; do
unzip -o "$zip_file"
done
Extract 25 zip archive files at once
find . -maxdepth 1 -name '*.zip' -print0 | xargs -0 -I {} -P 25 unzip "{}"
Set a password for a zip file
zip -P mypassword archive.zip file1.txt file2.jpg
Extract files from a password-protected zip file
unzip -P mypassword archive.zip