How to Zip / Unzip a directory in Linux or Unix Environment

In Linux world Zip command is not as popular as Gzip probably because of its compression where as in Windows we use it more frequently than Gzip. Recently one of my colleague asked for a command to Zip a folder in Linux environment.  After Googling few websites I got below solution :

zip –r   <> <Folder1>

Here -r parameter recursively compresses the folder passed as parameter. 

This command will result compressed Folder1 with all its contents recursively in file. Here one thing I have noticed that Zip command reports error while Zipping Folders with name containing special characters like _ underscore or  hyphens – or . dots. Not sure why it happened, but I don’t have solution for it now.

If you want to reverse the zipped file back to folder you can use below command :

unzip -d /temp

This command will result to be extracted under temp path as Folder1 directory.


Post a Comment