Technology and General Blog

Gathering a number of data files into a single file is known as archiving, and “zip” is 1 of the commonly employed archive formats that arrive with lossless facts compression aid. Archiving data files is an successful way to conserve your machine’s storage and make it less complicated to transfer documents through e mail or FTP.
Linux has a created-in zip utility to archive the files with a set of choices. This utility gives many methods to archive the data files. When you archive a listing applying zip utility, it contains all the data files in that listing and zip it. So, is it attainable to archive a file and excluding the certain data files applying the “zip” utility? The reply is yes! The “zip” is a multipurpose Linux utility that allows you archive documents, excluding specified documents or folders. How does it occur? Let us start out:

How to exclude documents and directories when working with “zip” in Linux:

You can archive any directory excluding a specific file using the “-x” flag with the “zip” utility. The standard syntax is mentioned underneath:

$zip -r [] [files/folder to zip] -x [file path/name to exclude]

Let us realize it via an instance I have established a directory by the identify of “images” that is made up of 3 impression information, just one zipped file, and one sub-directory (my folder) as revealed in the following impression :

Now start terminal and kind:

$zip -r photos -x /photographs/img2.png

In the over command, I am compressing the “images” listing and excluding an impression file “img2.jpg” and saving it as “”

As it can be witnessed that “” did not include the “img2.jpg” file. You can also exclude file by mentioning the extension of the file for instance, I want to exclude all “.jpg” documents in the “images” listing and archive it:

$zip -r photographs -x *.jpg

All the “jpg” files have been excluded in the zip file. You can exclude several information and directories by mentioning them in the adhering to way:

$zip -r visuals -x /photographs/img2.jpg -x

/photographs/all_illustrations or

The “img2.jpg” and “” information will not be archived:


Holding the information in an archive will save a whole lot of your machine’s storage and assists regulate tons of information and folders. In Linux “zip” utility is applied to archive documents/directories. In this generate-up, we figured out how to use the “zip” utility to archive the directory, excluding a certain file or folder. The “zip” utility will come with quite practical alternatives for executing “zip –help” in the terminal.

Leave a Reply

Your email address will not be published. Required fields are marked *