Skip to content

"zip" command examples

Archive all files and directories recursively starting from the current directory using the highest compress level:

zip -r -9 archive.zip *

List of files in archive:

unzip -l archive.zip

List of particular files in archive:

unzip -l archive.zip chickchirik/readme.txt

Show to stdout the contents of a particular file in archive:

unzip -c archive.zip chickchirik/readme.txt

Extract files that match the specified mask to the specified directory:

unzip archive.zip *some*Test* -d dest_dir

Create archive with current date/time in its name:

zip -r "backup-`date +%Y%m%d-%H%M%S`.zip" *

Delete files from archive:

zip -d archive.zip logs/*

Unzip all archives at once (option 1):

unzip '*.zip'

Unzip all archives at once (option 2):

for z in *.zip; do unzip $z; done

zip with password:

zip --encrypt docs.zip *.doc