How to Zip Multiple Files in Unix

Techwalla may earn compensation through affiliate links in this story. Learn more about our affiliate and product review process here.
Image Credit: DragonImages/iStock/GettyImages

A common way to store and share sets of multiple files is to use the ZIP file format. A zip command compresses one or more files and bundles them into a single file. Most modern operating systems, including Microsoft Windows, macOS and forms of Unix and Linux, can handle ZIP files. If you use a Unix or Linux operating system, you may want to use the Unix zip command line tool to manage these files.

Advertisement

The Unix ZIP Command

Video of the Day

If you're on most modern Unix systems, you can use a command line tool simply called "zip" to zip multiple files. There's a separate Unix unzip tool to extract the files from a zip archive.

Advertisement

Video of the Day

To create a ZIP file, go to the command line and type "zip" followed by the name of the ZIP file you want to create and a list of files to include. For example, you could type "zip example.zip folder1/file1 file2 folder2/file3" to create a ZIP file called "example.zip" including compressed copies of the files at the three listed paths.

Advertisement

To use the Unix zip command for multiple files, include as many filenames as you want in the command line argument. If some of the files are directories or folders you want to include in their entirety, add the argument "-r" to recursively descend into the directories and include them in the zip archive.

Advertisement

After you create a file with the zip command, people should be able to open it on most operating systems.

Unix Unzip

If you have a ZIP file on a Unix computer and need to extract files from it, use the unzip command. Type "unzip" at the command line followed by the name of the ZIP file, such as "unzip example.zip."

Advertisement

Advertisement

The file is unzipped in the current directory. If you want to use the unzip command to list files in a ZIP file without actually extracting them, type "unzip -l" for the list option. This saves space and avoids filling a directory with files if you're not sure what's in a zip file.

Advertisement

Zip files can contain malware, so it's best to work with ZIP files only from people you trust.

Alternatives to Zip and Unzip

Zip and unzip aren't the only tools you can use to work with ZIP files on Unix systems.

Advertisement

Apple macOS includes native support for ZIP files, so you can double-click them to open them like other folders. Linux systems running the GNOME desktop environment often include a graphical tool called File Roller, and systems running the KDE environment often use one called Ark.

Unix users also use another system for bundling files known as tar, which is supported by command line tools that work similarly to the zip tools. In general, use "tar -c" to create a tar file and "tar -x" to extract one. The Unix manual contains other options that are available, including a variety of types of data compression similar to ZIP.

Advertisement

Advertisement

references