Skip to content
TrySitePrice

UNIX: Zip Example

Best/Tutorial

The zip command is a commonly used utility for compressing files and directories on Unix-like systems. Here are some examples of how to use the zip command:

  1. Compress a file:

    zip archive.zip file.txt

  2. Compress multiple files:

    zip archive.zip file1.txt file2.txt

  3. Compress a directory and its contents:

    zip -r archive.zip directory/

  4. Compress a directory and exclude certain files or subdirectories:

    zip -r archive.zip directory/ -x "directory/exclude*" "directory/subdirectory/exclude*"

  5. Compress a directory and set a password:

    zip -r -e archive.zip directory/ -P password

  6. Compress a directory and split the archive into multiple parts:

    zip -r -s 100M archive.zip directory/

    This will split the archive into parts of 100 MB each.

  7. Compress a file or directory and include a comment:

    zip -z "This is a comment" archive.zip file.txtrnzip -r -z "This is a comment" archive.zip directory/

    This will include the specified comment in the zip archive's central directory.

rnThese are just a few examples of how to use the zip command. For more information and options, you can check the man pages for zip by running man zip.