When I try

 unzip filename.zip

it works. However, I need to unzip a series of zip files.

Why are:

 find . -name "*.zip" -print0 | xargs -0 unzip


 ls *.zip | xargs unzip

not working?

In both cases I get a "caution: filename not matched: " message.

4 Answers 4


You can issue the command:

$ unzip '*.zip'

Look here for reference.

  • I didn't say it clearly, but they are not all in the same directory. So, I need the output of find. Aug 21, 2013 at 23:02
  • 4
    Thanks. This might nit match the actual question perfectly but this solved my problem. I was trying unzip * and it returned caution: filename not matched for every file but unzip '*.zip' did the job.
    – Ivan
    Aug 2, 2016 at 3:50

Your commands are not working because they stuff all the files onto the same command line. While that works with most programs, unzip will take the first argument as the zip file, and any after the first as files to extract from it. You need to execute the command once for each file:

find . -name "*.zip" -print0 | xargs -0 -n1 unzip


find . -name '*.zip' -exec unzip {} \;
  • The second one seems to be better in case there really are a lot of files. (Otherwise it complained the command is too long with xargs)
    – Recct
    Mar 16, 2015 at 11:58

In bash you could also do the following:

for i in *.zip; do
    unzip "$i"

Also unzip can take the -d switch so you can target the output to different locations.

For example:

for i in *.zip; do
    [ -d "$uzdir/$i" ] || mkdir -p "$uzdir/$i"
    unzip "$i" -d "$uzdir/$i"

There is a much easier solution than the looping ones given above, use the directory -d flag:

unzip -o somefiles.zip -d $directoryPath
  • -d specifies the dir to extract into, not the dir to look in for files. Jan 4, 2017 at 19:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.