≡ Menu

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

Sysadmin because even developers need heroes!!!

Share this tutorial on:
{ 27 comments… add one }
  • Kamchybek Jusupov March 6, 2007, 9:39 am

    # If files are password protected, and we are not sure which password

    for Z_FILE in *.zip; do
    for PASSWD in [ pass123, PASS123, abc123, ABC123 ]; do
    unzip -P $PASSWD $Z_FILE;
    if [ $? = 0 ]; then # successful unzip

  • Vivek Gite March 6, 2007, 10:52 am


    This is an excellent hack.

    Appreciate your post.

  • Kamchybek Jusupov March 21, 2007, 10:11 am

    > Appreciate your post.

    No probs, copyleft (c) :)

    Actually I’ve seen yours:

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

    But, it was not enough for me, ’cause we have password protected ones… So, can say that idea comes from you :) I just added a new feature (validation)…

    I think it should/can be improved further to check for other exit status codes…

    Maybe later some day…

  • Bobby Cox April 8, 2007, 2:54 am

    I used to use for i in *.zip ; do unzip $i ; done as well but then I found out about the following command and use it all the time now.

    unzip \*.zip

    escape the asterik and you are good to go. :)

  • Naresh July 26, 2007, 9:43 am


    I tried unzip -P $PASSWD $Z_FILE; command but it is not working and for same zip file it is working in US with same password. I read in one of the web sites that, non USA system needs to install a patch for running above command. If yes Please let me know where can I get this patch else please let me know how to run this command.


  • Oberg January 24, 2009, 4:05 pm

    Thanks, just what I needed! Very straitghtforward. +1 virtual cookie for you.

  • some dude April 25, 2009, 7:04 am

    If you have spaces in your filenames, you can also use the following:

    for z in *.zip; do unzip “$z”; done

  • Ragu May 11, 2009, 8:52 pm

    find -name \*.zip -exec unzip {} \;

    find -name \*.zip | xargs -t -i unzip {}

  • moshe beeri May 31, 2009, 12:08 pm

    If you like to extract multiple tar or tar.gz use the following command
    for f in *.tar.gz; do tar zxf $f; done

  • Kaithy Aravind Reddy December 27, 2009, 4:30 am

    Thanks all for sharing, very useful information about Unzip.

  • eladio matos February 18, 2010, 6:01 pm

    Question: and if I want do delete a file in a batch of different compressed archives? Lets say all copies of “info.txt” or “logo.jpg” in a.zip, b.zip, c.zip(…) z.zip, etc. There is a way to do it?

  • vipin kumar January 12, 2012, 5:26 am

    excellent post …. short method is really awesome..

  • Jane January 16, 2012, 12:41 pm

    Exactly what I was looking for! THANK YOU!

  • Paul February 21, 2012, 12:10 pm

    Time saver, life saver! Thank you!

  • pradeep chourasiya May 22, 2012, 5:52 am

    thanks a lot …..4 help

    if u want to display some msg then…

    for z in *.zip;
    do unzip $z;
  • Radina October 23, 2012, 5:37 pm

    Thanks everyone for the answers. If space is an issue, you can do something like (from some dude) to remove the archive files as they are unpackaged:
    for z in *.zip; do unzip $z; rm $z; done

  • sarita November 3, 2013, 4:54 am

    I have 1..10 zip files in one directory …i want to unzip all files at a time..
    can any one help how to do that

  • Tarun Nagpal January 26, 2014, 12:39 pm

    Thank you very much.

  • Tony September 13, 2014, 6:07 pm

    I used:

    unzip “*.zip” -d ~/.fonts/

  • Speppa January 29, 2015, 9:08 am

    Thank you very much, on my Debian option #2 works very well!

  • LeQuebecois-rigolo January 19, 2016, 8:06 am

    I had a pile of zip that each contained a index.html file and the archive structure had no folder.. They obviously had to be extracted in separate folders so as to not overwrite the so precious files. Since it was a temporary “view and delete” kind of thing and with well over a hundred files (not needing to be unzipped in a specific folder, current folder was just fine), i came up with this;

    for z in *.zip; do q=$(echo $z | cut -f 1 -d '.'); unzip $z -d ./$q; done;

    It basically extracts all the zip files to the current directory, into a folder named after the zip filename. Greatly inspired (if not totally ripped from!) NixCraft and http://stackoverflow.com/questions/12152626/how-can-remove-the-extension-of-a-filename-in-a-shell-script

    Couple seconds after i figured “oh well”, i saved that much time so i might as well make something out of it… So instead of just ‘hardcoding’ it into a simple bash alias that doesn’t take parameters, I took a couple more minutes to have it let me at least input a base directory for extraction. Here’s what i came up with (function in .bashrc file);

    unzipALL() {
    [[ ! -z "${1// }" ]] && dir=$1;
    for z in *.zip; do
    q=$(echo $z | cut -f 1 -d '.');
    unzip $z -d $dir/$q;

    From the command line just use unzipAll to unzip to the current folder or pass it a folder name: unzipAll /tmp extracts all to /tmp/%filename%.

    It does perform a single basic check on the passed parameter but nothing too fancy (strip spaces before/after then checks against null). One could spend more time and cutomize it further, adding bad directory check and all that…

    I figure i’d share… thanks and hopefuly it can be of use to someone!

    I hope i didn’t break any rules posting a url in here, sorry if so heeh

    • Vivek Gite January 19, 2016, 12:04 pm

      Awesome job and thanks for sharing it with us.

  • Nan Xiao January 20, 2016, 2:25 am

    unzip “*.zip” should also be OK.

    • LeQuebecois-rigolo January 21, 2016, 2:30 am

      unzip *.zip does not work in bash.

      blah@blahblah:~/tmp-zip$ unzip *.zip
      Archive: test1.zip
      caution: filename not matched: test2.zip

      unzip \*.zip DOES work, still doesn’t solve the problem i faced of multiple same-name files…

      blah@blahblah:~/tmp-zip$ unzip \*.zip
      inflating: index.html
      inflating: portfolio.html
      inflating: services.html
      Archive: test2.zip
      replace index.html? [y]es, [n]o, [A]ll, [N]one, [r]ename:

      unzip “*.zip” results in the same, btw.

      Hence the quick function. If you have a better way please share
      Also, while testing you assumptions, i found out that unzip tries to look for .ZIP files on it’s own – pretty neat… unzip \* would work (still not help with the issue…)

  • Thomas January 28, 2016, 4:00 pm

    I just pulled a lot of files (over 400K) all of them were in zip, i’m trying to make huge archive off free documents at http://uploadcoins.com , so for me worked # unzip \*.zip , all that 400K went ok :) , so again, You can use unzip \*.zip , Good luck

  • PKaran January 29, 2016, 12:09 pm

    I want a script to extract a particular file from the multiple zip folder.


  • David June 14, 2016, 9:40 pm

    unzip \*.zip

Security: Are you a robot or human?

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">

   Tagged with: