YouTip LogoYouTip

Linux Comm Unzip

Linux unzip Command

Linux unzip Command

-- Learning not only technology, but also dreams!

Linux Tutorial

Shell Tutorial

Linux Reference Manual

Shell File Inclusion

Nginx Installation and Configuration

Deep Dive

  • Computer Science
  • Software
  • Programming Languages
  • Development Tools
  • Web Design and Development
  • Scripting
  • Scripting Languages
  • Web Services
  • Network Services
  • Programming

Linux unzip Command

Image 3: Linux Command Manual Linux Command Manual

The Linux unzip command is used to decompress .zip format compressed files.

The unzip tool can decompress .zip files containing multiple files and directories and is widely used for handling cross-platform compressed files.

Syntax

unzip  file.zip
  • file.zip: The .zip file to decompress.

Options parameters:

  • -d <directory>: Place decompressed files into the specified directory.
  • -l: List the contents of the .zip file without decompressing.
  • -v: Display detailed information, including the structure and compression ratio of the .zip file.
  • -t: Test the integrity of the .zip file without decompressing.
  • -n: Do not overwrite existing files during decompression.
  • -o: Overwrite existing files during decompression without prompting.
  • -x <pattern>: Exclude specified files or directories during decompression.
  • -j: Do not preserve directory structure during decompression; extract all files to the current directory.

Examples

Decompress a .zip file

unzip archive.zip

This command will decompress the contents of archive.zip into the current directory.

Decompress to a specified directory

unzip archive.zip -d /path/to/directory

This command will decompress the contents of archive.zip into the specified /path/to/directory directory.

List the contents of a .zip file

unzip -l archive.zip

This command will list all files and directories in archive.zip without actually decompressing them.

Test the integrity of a .zip file

unzip -t archive.zip

This command will test the integrity of the archive.zip file to ensure it is not corrupted.

Exclude specific files during decompression

unzip archive.zip -x "*.log"

This command will decompress archive.zip, but exclude all .log files.

Do not overwrite existing files during decompression

unzip -n archive.zip

This command will decompress the files from archive.zip, but if a file with the same name already exists in the target directory, it will skip that file and not overwrite it.

Decompress files and overwrite existing files

unzip -o archive.zip

This command will overwrite any existing files with the same name in the target directory during the decompression of archive.zip, without prompting the user.

Decompress without preserving directory structure

unzip -j archive.zip

This command will decompress all files from archive.zip into the current directory without preserving the original directory structure.

Notes

  • unzip preserves the original directory structure by default during decompression. If you do not need to preserve the directory structure, you can use the -j option.
  • unzip can exclude certain files or directories using the -x option, which is useful for selectively decompressing specific files.

Image 4: Linux Command Manual Linux Command Manual

← Os MkfifoOs Mkdir β†’