Example Uses of the Linux Command 'unzip'

The 'unzip' command varies through the use of command switches

The following examples illustrate typical uses of the command unzip for unpackaging archive files. The archive files are assumed to be generated using software such as zip, which uses the standard zip-file format.

Binary Unzip
Kelly Sillaste / Getty Images

Sample Uses

To use unzip to extract all members of the archive letters.zip into the current directory and subdirectories below it, creating any subdirectories as necessary:

unzip letters 

To extract all members of letters.zip into the current directory only:

unzip -j letters 

To test letters.zip, printing only a summary message indicating whether the archive is OK or not:

unzip -tq letters 

To test all zipfiles in the current directory, printing only the summaries:

unzip -tq \*.zip 

The backslash before the asterisk is only required if the shell expands wildcards, as in Unix; double quotes could have been used instead, as in the source examples below.

To extract to standard output all members of letters.zip whose names end in .tex, auto-converting to the local end-of-line convention and piping the output into more:

unzip -ca letters \*.tex | more 

To extract the binary file paper1.dvi to standard output and pipe it to a printing program:

unzip -p articles paper1.dvi | dvips 

To extract all FORTRAN and C source files--*.f, *.c, *.h, and Makefile--into the /tmp directory:

unzip source.zip "*.[fch]" Makefile -d /tmp 

To extract all FORTRAN and C source files, regardless of case (e.g., both *.c and *.C, and any makefile, Makefile, MAKEFILE or similar):

unzip -C source.zip "*.[fch]" makefile -d /tmp 

To extract any such files but convert any uppercase MS-DOS or VMS names to lowercase and convert the line-endings of all of the files to the local standard (without respect to any files that might be marked ``binary''):

unzip -aaCL source.zip "*.[fch]" makefile -d /tmp 

To extract only newer versions of the files already in the current directory, without querying:

unzip -fo sources

To extract newer versions of the files already in the current directory and to create any files not already there:

unzip -uo sources 

To display a diagnostic screen showing which unzip and zipinfo options are stored in environment variables, whether decryption support was compiled in, the compiler with which unzip was compiled, etc.:

unzip -v 

In the last five examples, assume that UNZIP or UNZIP_OPTS is set to -q. To do a singly quiet listing:

unzip -l file.zip

To do a doubly quiet listing:

unzip -ql file.zip 
Was this page helpful?