How To Zip, Unzip Files In Linux?
Winzip, Winrar are popular packaging and compression tools for Windows operating system. Winzip was very popular in old times and this made zip compression algorithm popular too. Currenly a lot of file and folders are compressed with zip algorithm too. Zip compression is supported by Minix, Atari, MacOS, Android too. We look look how to compress and decompress with zip algorithm in this post
To use zip functionality required packages should be downloaded they are not installed by default
$ sudo apt-get install zip unzip -y
Compress With Zip
How to zip a file? We can use zip command like below
zip options archive inpath inpath ...
Let’s compress some file
$ zip test.zip newtextfile
Compress Multiple Files With Zip
We can compress multiple files with zip we will add all file and folders at the end of the command as parameter
$ zip test.zip backup.zip .ssh .bashrc
Compress Multiple Files With Extension
We will compress all png files in this directory.
$ zip test.zip *.png
Compressing files requires no option to zip command but cmpressingg folders requires recursive flag to the zip command.
$ zip -r test.zip output2
Compress File By Searching Them
We can use find command to search files to zip. The files found by find will zipped .
$ find . -name "*.png" -print | zip source -@
Decompress Zip Files
Decompressing is easier than compressing we just provide archive file to unzip command. How to unzip a file?
$ unzip test.zip
Extract Specific File From Zip Archive
We can decompress specific file from a zip archive like below
$ unzip test.zip *rc
This will extract only files ends with rc