how to zip a directory in unix

Zip is like a container in which you compress the files and contain huge data. When you want to transfer a huge data to another place. Then you compress the files and transfer data. you save the zip files using .zip extension. Today websites have heavy data when you want to download some files then you download in compressed form. you save these files using .zip extension and compress files using software which is installed in your system. Today almost every operating system has zip system like UNIX, mac and windows etc. here you use unix you should know that how to zip a directory in UNIX.

How top zip folder using zip command in UNIX:

You can zip the files in UNIX by using the zip command. There are many option to zip files, when you use zip command as well as you use many other option like ‘-r’ ‘f’ ‘u’ ‘d’ ‘m’ ‘j’ ‘o’ ‘9’ ‘q’ ‘v’ ‘c’ and there are many others every option have its own characteristics. But here you use ‘-r’ option. If you want to zip folder you write these lines of code:

$ zip –r <output_file>  <folder_1>  <folder_2>  … <folder_n>

If you want to archive a folder name ‘arzhost’ in zip file which is ‘’. for achieve this task you use these commands:

                            $ zip –r arzhost

If you want to see that our zip file is created or not then you use ‘Is’ command for archive file.

                                    $ Is – I  |  grep .zip 

If you didn’t know that where your zip file is store then you use these lines of code to find oyour files.

 $ find  /  -name  * .zip  2>  /dev/null 

Zip the folder using FIND option:

One of the most power full command is to zip files into your folders. you use ‘FIND’ command and link it to ‘exec’ option for execute the zip command. If you want to zip your folders in current working directory then you use these lines of code.

                 $ find . -maxdepth 1 -type d -exec zip {} +\     

zip folder using find

 How to zip directories using bash system:   

you can zip folders using bash programming language. Sometime you haven’t any GUI then you can zip files in CLI using bash programming. If you want to zip any folder in bash language then you use ‘for loop’. you follow these lines of code:

                   $ for file in $(ls -d */); do zip $file; done  

zip directories using bash

If you want to zip a folder which is start with any letter e.g. E .A folder is start with E letter then you follow these lines of code:

                  $ for file in $(ls -d */ | grep E); do zip $file; done 

zip a folder

you have to zip our folder successfully.


by reading this article we hope that you know how to zip a directory in UNIX.




Flash Sale

Hurry Up! Offer ends in
01 days
10 hrs
50 mins
19 secs
Buy Now