Bash Wiki
Posts (Latest 30 updated) :
Read all
Contents:
  1. [Linux] Bash unzip uso: Extract files from zip archives
    1. Overview
    2. Usage
    3. Common Options
    4. Common Examples
    5. Tips

[Linux] Bash unzip uso: Extract files from zip archives

Overview

The unzip command is used to extract files from ZIP archives in a Linux environment. It allows users to decompress and access the contents of compressed files easily.

Usage

The basic syntax of the unzip command is as follows:

unzip [options] [arguments]

Common Options

  • -l: List the contents of a ZIP file without extracting.
  • -d <directory>: Specify the directory to extract files into.
  • -o: Overwrite existing files without prompting.
  • -q: Perform the operation quietly, suppressing output messages.
  • -x <file>: Exclude specific files from being extracted.

Common Examples

  1. Extracting a ZIP file in the current directory:
    unzip archive.zip
    
  2. Extracting a ZIP file to a specific directory:
    unzip archive.zip -d /path/to/directory
    
  3. Listing the contents of a ZIP file:
    unzip -l archive.zip
    
  4. Extracting a ZIP file and overwriting existing files:
    unzip -o archive.zip
    
  5. Extracting a ZIP file while excluding certain files:
    unzip archive.zip -x unwanted_file.txt
    

Tips

  • Always check the contents of a ZIP file with the -l option before extraction to avoid overwriting important files.
  • Use the -d option to keep your files organized by extracting them into a designated folder.
  • If you frequently deal with ZIP files, consider creating an alias for the unzip command to streamline your workflow.