Linux unzip Command
The Linux unzip command is used to extract zip files.
unzip is a program for extracting compressed files in .zip format.
Syntax
unzip [-cflptuvz][-agCjLMnoqsVX][-P <password>][.zip file][files][-d <directory>][-x <files>] or unzip [-Z]
Parameters:
- -c: Displays the unzipped content on the screen and performs appropriate character conversions.
- -f: Updates existing files.
- -l: Lists the files contained in the compressed file.
- -p: Similar to the -c parameter, displays the unzipped content on the screen but does not perform any conversions.
- -t: Checks if the compressed file is correct.
- -u: Similar to the -f parameter, but also extracts other files from the compressed file into the directory.
- -v: Displays detailed information during execution.
- -z: Displays only the comments of the compressed file.
- -a: Performs necessary character conversions for text files.
- -b: Does not perform character conversions for text files.
- -C: Case-sensitive file names in the compressed file.
- -j: Does not process the original directory paths in the compressed file.
- -L: Converts all file names in the compressed file to lowercase.
- -M: Sends the output to the more program for processing.
- -n: Prevents overwriting existing files during extraction.
- -o: Overwrites existing files without asking the user.
- -P<password>: Uses the password option for zip.
- -q: Executes without displaying any information.
- -s: Converts whitespace characters in file names to underscores.
- -V: Retains VMS file version information.
- -X: Restores the original UID/GID of the files during extraction.
- [.zip file]: Specifies the .zip compressed file.
- [files]: Specifies which files in the .zip compressed file to process.
- -d<directory>: Specifies the directory where the extracted files will be stored.
- -x<files>: Specifies which files in the .zip compressed file not to process.
- -Z: unzip -Z is equivalent to running the zipinfo command.
Examples
View the files contained in the compressed file:
# unzip -l abc.zip
Archive: abc.zip
Length Date Time Name
-------- ---- ---- ----
94618 05-21-10 20:44 a11.jpg
202001 05-21-10 20:44 a22.jpg
16 05-22-10 15:01 11.txt
46468 05-23-10 10:30 w456.JPG
140085 03-14-10 21:49 my.asp
-------- -------
483188 5 files
The -v parameter is used to view the directory information of the compressed file without extracting it.
# unzip -v abc.zip
Archive: abc.zip
Length Method Size Ratio Date Time CRC-32 Name
-------- ------ ------- ----- ---- ---- ------ ----
94618 Defl:N 93353 1% 05-21-10 20:44 9e661437 a11.jpg
202001 Defl:N 201833 0% 05-21-10 20:44 1da462eb a22.jpg
16 Stored 16 0% 05-22-10 15:01 ae8a9910 ? +-|¥+-? (11).txt
46468 Defl:N 39997 14% 05-23-10 10:30 962861f2 w456.JPG
140085 Defl:N 36765 74% 03-14-10 21:49 836fcc3f my.asp
-------- ------- --- -------
483188 371964 23% 5 files