📅  最后修改于: 2023-12-03 14:48:13.889000             🧑  作者: Mango
If you're a programmer working with Linux, chances are you need to extract zip files on a regular basis. The command line tool for this task is unzip
, and in this tutorial, we'll cover everything you need to know to get started with it.
Most Linux distributions already have unzip
installed by default, but if you don't have it, you can install it with the following commands:
Debian/Ubuntu:
sudo apt-get install unzip
Red Hat/Fedora:
sudo yum install unzip
The basic syntax for unzip
is:
unzip [options] file.zip
For example, to extract a zip file called archive.zip
, you would run:
unzip archive.zip
By default, unzip
will extract the contents of the zip file to the current directory.
If you want to extract the contents of a zip file to a different directory, you can use the -d
option followed by the desired path:
unzip archive.zip -d /path/to/directory
If you want to see a list of the files contained in a zip file without extracting them, you can use the -l
option:
unzip -l archive.zip
If you only want to extract specific files from a zip file, you can specify their names after the zip file name:
unzip archive.zip file1.txt file2.txt
If the zip file is password-protected, you can provide the password with the -P
option:
unzip -P password archive.zip
unzip
is a powerful and versatile tool for extracting zip files from the command line. With the options covered in this tutorial, you should be able to handle most zip file extraction tasks on Linux.