UNIX: Zip Example
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:
- Compress a file:
zip archive.zip file.txt - Compress multiple files:
zip archive.zip file1.txt file2.txt - Compress a directory and its contents:
zip -r archive.zip directory/ - Compress a directory and exclude certain files or subdirectories:
zip -r archive.zip directory/ -x "directory/exclude*" "directory/subdirectory/exclude*" - Compress a directory and set a password:
zip -r -e archive.zip directory/ -P password - 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.
- 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.
zip command. For more information and options, you can check the man pages for zip by running man zip.