How do I unzip multiple / many files under Linux?

I have lots of files in a directory called /disk2/images/. All files are in zip file format, so I am using the following command to extract zip files:
     unzip *.zip
The command result into an error which read as follows:
     caution: filename not matched
How do I unzip multiple or many zip files under a Linux/Unix-like system?

Linux or Unix-like system use the unzip command to list, test, or extract files from a ZIP archive, commonly found on MS-DOS systems.

The problem with multiple zip files on Linux

Assuming that you have four file in a /disk2/images/ directory as follows:

  1. pictures.zip
  2. visit.zip
  3. data.zip
  4. invoices.zip

Let us verify it with the ls command:
$ ls
Sample outputs:

data.zip	invoices.zip	pictures.zip	visit.zip

To unzip all files, enter:
$ unzip *.zip
Sample outputs:

Archive:  data.zip
caution: filename not matched:  invoices.zip
caution: filename not matched:  pictures.zip
caution: filename not matched:  visit.zip

Above error indicate that you used the unzip command wrongly. It means extract invoices.zip, pictures.zip, and visit.zip files from inside the data.zip archive. Your shell expands the command ‘unzip *.zip’ it as follows:
unzip data.zip invoices.zip pictures.zip visit.zip
The solution is pretty simple when you want to unzip the file using the wild card; you have two options as follows.

#1: Unzip Multiple Files Using Single Quote (short version)

The syntax is as follows to unzip multiple files from Linux command line:

unzip '*.zip'

Type the following command as follows:
$ cd /disk2/images/
$ unzip '*.zip'
$ ls -l

Note: *.zip is put in between two single quotes so that shell will not recognize it as a wild card character.

#2: Unzip Multiple Files from Linux Command Line Using Shell For Loop (Long Version)

You can also use for loop as follows:

 for z in *.zip; do unzip $z; done
See also

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.