How to decompress multiple files using the unzip command in Linux

How to decompress multiple files using the unzip command in Linux

Solution to the problem that there is no unzip command in Linux

If you use the unzip command to unzip the .zip file, it may be that you do not have the unzip software installed. Here is how to install it

Command: yum list | grep zip/unzip #Get the installation list

Installation command: yum install zip #When prompted, enter y;

Installation command: yum install unzip #When prompted, enter y;

Directly using unzip *.zip to decompress multiple files in Linux will result in an error

You can use unzip '*.zip' or unzip "*.zip" or unzip \*.zip command

Or use for z in *.zip; do unzip $z; done to perform decompression

As shown below, there are 6 zip compressed files in the current directory

[root@autoServer COLLECTION]# ll -s
total 24
4 -rw-r--r--. 1 root root 1681 Sep 11 15:38 00004.zip
4 -rw-r--r--. 1 root root 1325 Sep 11 15:38 00005.zip
4 -rw-r--r--. 1 root root 1540 Sep 11 15:43 00010.zip
4 -rw-r--r--. 1 root root 1392 Sep 11 15:43 00011.zip
4 -rw-r--r--. 1 root root 1541 Sep 11 15:48 00016.zip
4 -rw-r--r--. 1 root root 1390 Sep 11 15:48 00017.zip

Use unzip \*.zip command to decompress, and you can see that all 6 files are decompressed successfully.

[root@autoServer COLLECTION]# unzip \*.zip
Archive: 00005.zip
 inflating: GAB_ZIP_INDEX.xml  
 inflating: 15366516000003-BASIC_1004.bcp 

Archive: 00010.zip
replace GAB_ZIP_INDEX.xml? [y]es, [n]o, [A]ll, [N]one, [r]ename: n  
 inflating: 15366518460006-SOURCE_1001.bcp 

Archive: 00016.zip
replace GAB_ZIP_INDEX.xml? [y]es, [n]o, [A]ll, [N]one, [r]ename: A
 inflating: GAB_ZIP_INDEX.xml  
 inflating: 15366519060012-SOURCE_1001.bcp 

Archive: 00017.zip
 inflating: GAB_ZIP_INDEX.xml  
 inflating: 15366519080014-SOURCE_1002.bcp 

Archive: 00004.zip
 inflating: GAB_ZIP_INDEX.xml  
 inflating: 15366516000001-BASIC_1003.bcp 

Archive: 00011.zip
 inflating: GAB_ZIP_INDEX.xml  
 inflating: 15366518480008-SOURCE_1002.bcp 

6 archives were successfully processed.

Check the current directory to see if there is an unzipped file.

[root@autoServer COLLECTION]# ll -s
total 52
4 -rw-r--r--. 1 root root 294 Sep 11 15:40 15366516000001-BASIC_1003.bcp
4 -rw-r--r--. 1 root root 158 ​​Sep 11 15:40 15366516000003-BASIC_1004.bcp
4 -rw-r--r--. 1 root root 104 Sep 11 15:45 15366518460006-SOURCE_1001.bcp
4 -rw-r--r--. 1 root root 80 Sep 11 15:45 15366518480008-SOURCE_1002.bcp
4 -rw-r--r--. 1 root root 104 Sep 11 15:50 15366519060012-SOURCE_1001.bcp
4 -rw-r--r--. 1 root root 80 Sep 11 15:50 15366519080014-SOURCE_1002.bcp
4 -rw-r--r--. 1 root root 1681 Sep 11 15:38 00004.zip
4 -rw-r--r--. 1 root root 1325 Sep 11 15:38 00005.zip
4 -rw-r--r--. 1 root root 1540 Sep 11 15:43 00010.zip
4 -rw-r--r--. 1 root root 1392 Sep 11 15:43 00011.zip
4 -rw-r--r--. 1 root root 1541 Sep 11 15:48 00016.zip
4 -rw-r--r--. 1 root root 1390 Sep 11 15:48 00017.zip
4 -rw-r--r--. 1 root root 2056 Sep 11 15:45 GAB_ZIP_INDEX.xml

Unzip usage additional commands

Unzip the file to the current directory

unzip test.zip

To unzip the file to the specified directory, you need to use the -d parameter

unzip -d /temp test.zip

To not overwrite existing files after decompression, use the -n parameter; to decompress in overwriting mode, use the -o parameter

unzip -n test.zip
unzip -n -d /temp test.zip

Decompress the compressed file test.zip in the specified directory tmp. If the same file already exists, use -o to overwrite the original file.

unzip -o test.zip -d /tmp/

To only view the sub-files contained in the zip archive without decompressing it, use the -l parameter

unzip -l test.zip

To view the displayed file list, also include the compression ratio, use the -v parameter

unzip -v test.zip

Check if the zip file is damaged, use the -t parameter

unzip -t test.zip

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. If you have any questions, you can leave a message to communicate. Thank you for your support for 123WORDPRESS.COM.

You may also be interested in:
  • Detailed explanation of zip compression and unzip decompression commands and their usage in Linux
  • Solution to Chinese garbled characters when unzipping in Linux
  • Detailed explanation of Linux command unzip

<<:  Linux installation MySQL5.6.24 usage instructions

>>:  How to use node scaffolding to build a server to implement token verification

Recommend

Discussion on horizontal and vertical centering of elements in HTML

When we design a page, we often need to center th...

A brief comparison of Props in React

Table of contents Props comparison of class compo...

Javascript Basics: Detailed Explanation of Operators and Flow Control

Table of contents 1. Operator 1.1 Arithmetic oper...

Linux system calls for operating files

Table of contents 1. Open the file Parameter Intr...

Specific use of GNU Parallel

what is it? GNU Parallel is a shell tool for exec...

How to upgrade CentOS7 to CentOS8 (detailed steps)

This article uses a specific example to introduce...

Detailed Introduction to the MySQL Keyword Distinct

Introduction to the usage of MySQL keyword Distin...

About the overlap of margin value and vertical margin in CSS

Margin of parallel boxes (overlap of double margi...

React-native sample code to implement the shopping cart sliding deletion effect

Basically all e-commerce projects have the functi...

CSS transparent border background-clip magic

This article mainly introduces the wonderful use ...

How to implement second-level scheduled tasks with Linux Crontab Shell script

1. Write Shell script crontab.sh #!/bin/bash step...

Detailed explanation of MySQL index selection and optimization

Table of contents Index Model B+Tree Index select...