Archiving and compressing with zip
ZIP is a popular compressed archive format available on Linux, Mac, and Windows. It isn't as commonly used as gzip
or bzip2
on Linux but is useful when distributing data to other platforms.
How to do it...
- The following syntax creates a zip archive:
$ zip archive_name.zip file1 file2 file3...
Consider this example:
$ zip file.zip file
Here, the file.zip
file will be produced.
- The
-r
flag will archive folders recursively:
$ zip -r archive.zip folder1 folder2
- The
unzip
command will extract files and folders from a ZIP file:
$ unzip file.zip
The unzip command extracts the contents without removing the archive (unlike unlzma
or gunzip
).
- The
-u
flag updates files in the archive with newer files:
$ zip file.zip -u newfile
- The
-d
flag deletes one or more files from a zipped archive:
$ zip -d arc.zip file.txt
- The
-l
flag to unzip lists the files in an archive:
$ unzip -l archive.zip
How it works...
While being similar to most of the archiving and compression...