Untitled Document
zip Command

zip - commands performs the two operations - Compressing and Archiving of files together . zip requires the first argument to be the compressed filename , the remaining are interpretted as files and directories to be compressed . The compression with zip command can be achieved in following ways -


Example 1 - Basic Example

Below example with archive and zip three files together .

   zip archive.zip user.txt logs.txt emp.csv  

Example 2 - Recursive compression ( -r ) option -

For recursive behavior , zip uses the -r option . It descends the tree structure in the same way tar does except that it also compress files.The below command wil zip all the files and directories from output directory .

   zip -r output.zip c/mangesh/ouput     


Example 1 - unzip files

Files are restored with unzip command , which in its simplest form , uses the compressed filename as wrgument . Here is the command to unzip above examples .

   unzip -r output.zip     

Example 2 - viewing the unzip files ( -v ) option -

We can view the compressed archive with the -v option . The list shows both the compressed and uncompressed size of each file in the archive along with the percentage of compression achieved .

   unzip -v output.zip     
Untitled Document