cmd line tutorials - gencmd

cmd line tutorials - gencmd

The zip Command

Unix-Linux Mac

The zip command is used to create archive files.

Syntax

The basic syntax for the zip command is as follows:

zip [options] <archive_name> <file1> <file2> ...

The <archive_name> argument is the name of the archive file that you want to create. The <file1>, <file2>, … arguments are the names of the files that you want to add to the archive file.

Examples

Here are some examples of how to use the zip command:

Create a ZIP archive file named “my_archive.zip” containing the files “myfile1.txt” and “myfile2.txt”.

zip my_archive.zip myfile1.txt myfile2.txt

Create a ZIP archive file named “my_archive.zip” containing all of the files in the current directory.

zip my_archive.zip *

Options

The zip command has a number of options that can be used to modify its behavior. Some of the most common options are:

-r: Recursively compress directories and their contents.

-9: Compress the files to the highest possible compression level.

-e: Encrypt the archive file using a password.

-t: Test the archive file to make sure that it is valid.

For more information on the zip command and its options, please see the man page: man zip.

With gencmd

gencmd -c zip compress files in a folder at a medium compression level and add a password

  • zip -r -m -9 -P <password> <folder>.zip <folder>