O'Reilly logo

Linux Shell Scripting Cookbook by Sarath Lakshman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Archiving and compressing with zip

ZIP is a popular compression format used on many platforms. It isn't as commonly used as gzip or bzip2 on Linux platforms, but files from the Internet are often saved in this format.

How to do it...

In order to archive with ZIP, the following syntax is used:

$ zip archive_name.zip [SOURCE FILES/DIRS]

For example:

$ zip file.zip file

Here, the file.zip file will be produced.

Archive directories and files recursively as follows:

$ zip -r archive.zip folder1 file2

In this command, -r is used for specifying recursive.

Unlike lzma, gzip, or bzip2, zip won't remove the source file after archiving. zip is similar to tar in that respect, but zip can compress files where tar does not. However, zip adds compression too.

In ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required