Dash Wiki
Posts (Latest 10 updated) :
Read all
Contents:
  1. [English] Debian Almquist Shell (dash) zip Usage: Compress files and directories
    1. Overview
    2. Usage
    3. Common Options
    4. Common Examples
    5. Tips

[English] Debian Almquist Shell (dash) zip Usage: Compress files and directories

Overview

The zip command is used to create compressed archive files in the ZIP format. It allows users to bundle multiple files and directories into a single file, reducing storage space and making it easier to transfer data.

Usage

The basic syntax of the zip command is as follows:

zip [options] [zipfile] [files]

Common Options

  • -r: Recursively zip directories.
  • -e: Encrypt the zip file with a password.
  • -9: Use the best compression method.
  • -q: Quiet mode; suppresses output messages.
  • -d: Delete specified files from the zip archive.

Common Examples

Here are some practical examples of using the zip command:

  1. Creating a zip file from multiple files:
    zip archive.zip file1.txt file2.txt file3.txt
    
  2. Creating a zip file from a directory:
    zip -r archive.zip my_directory/
    
  3. Creating an encrypted zip file:
    zip -e secure_archive.zip file1.txt file2.txt
    
  4. Adding files to an existing zip archive:
    zip archive.zip newfile.txt
    
  5. Deleting a file from a zip archive:
    zip -d archive.zip file1.txt
    

Tips

  • Use the -9 option for maximum compression when file size is a priority.
  • Consider using the -q option if you want to run the command in scripts without cluttering the output.
  • Always check the contents of your zip file with unzip -l archive.zip before sharing it to ensure all necessary files are included.