Forrest logo
back to the zip tool

zip:tldr:31801

zip: Archive files/directories e[x]cluding specified ones.
$ zip -r ${path-to-compressed-zip} ${filename_or_directory1 filename_or_directory2 ---} -x ${path-to-excluded_files_or_directories}
try on your machine

The command zip -r ${path-to-compressed-zip} ${filename_or_directory1 filename_or_directory2 ---} -x ${path-to-excluded_files_or_directories} is used to create a compressed zip archive and include specific files or directories while excluding certain files or directories.

Let's break down the command:

  • zip: This is the command-line utility for compressing files and creating zip archives.
  • -r: It stands for "recursive" and is used to include subdirectories and their contents.
  • ${path-to-compressed-zip}: This is the path where the compressed zip file will be created. You need to provide the desired location and name for the zip file.
  • ${filename_or_directory1 filename_or_directory2 ---}: These are the files or directories that you want to include in the zip archive. You can list multiple files or directories separated by spaces.
  • -x: It is used to specify the exclusion list.
  • ${path-to-excluded_files_or_directories}: This is the path to the files or directories that you want to exclude from the zip archive. Again, you can list multiple paths separated by spaces.

Overall, this command will compress specified files or directories into a zip archive, while excluding any files or directories mentioned in the exclusion list.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the zip tool