Linux Command - zip

zip - Package and compress (archive) files into zip file. You can use zipinfo command to list the files in zip format.

Syntax

1
zip [OPTION] archive inpath inpath...

Options

Option Description
-r recursive
-x exclude files
-d remove entry from archive
-q quiet
-v verbose mode or print diagnostic version info

Example

create compressed archive

1
zip -rq compressed.zip *

archive all the files in the current directory and subdirectories to create compressed.zip. Don’t show the output.

1
zip compressed.zip *

archive all the files in the current directory to create compressed.zip, excluding the files in subdirectories.

You can use vi compressed.zip command to view the content of a zip file.

Remove file from archive

1
zip -d compressed.zip file1

will remove file1 from compressed.zip

Unzip compressed archive

use unzip command to unzip compressed archive to the current directory.

1
unzip compressed.zip

Use -d argument to set an optional directory to which to extract files

1
unzip myapp.zip -d myapp

Reference