77

While trying to unzip a file named Joomla_3.0.3-Stable-Full_Package.zip to the directory named joomla I get filename not matched. Why is that?

# unzip -Z Joomla_3.0.3-Stable-Full_Package.zip /opt/lampp/htdocs/joomla/ Archive: Joomla_3.0.3-Stable-Full_Package.zip caution: filename not matched: /opt/lampp/htdocs/joomla/ 

Here is the screen cast of the directory:

joomla screen cast

(The joomla directory is empty)

1
  • 7
    i hit this error when i forgot to put a -d before my exdir argument Commented Nov 15, 2020 at 23:50

7 Answers 7

76

You can also get this when trying to specify the files to unzip and using a wildcard character. For example:

unzip -o somearchive.zip somedir/* 

What may happen is that bash expands somedir/* to an actual existing dir and the files it contains. That list is then passed to unzip and it tries to find these files in the zip file.

To prevent this behavior just escape the * like this:

unzip -o somearchive.zip somedir/\* 

Or, put the files to extract in double quotes:

unzip -o somearchive.zip "somedir/*" 
5
  • 3
    What's the -o flag? Commented Oct 5, 2016 at 22:21
  • 2
    The -o option is to overwrite existing files without prompting. Commented Oct 6, 2016 at 18:29
  • You might also get the 'Filename not matched' error when your -o flag is in the wrong place: unzip -o ARCHIVE_NAME.zip is good while unzip ARCHIVE_NAME.zip -o is bad Commented Dec 28, 2018 at 23:38
  • 8
    Downvoting because, although this answer makes true statements, they don’t address the issue the OP has, which is a misunderstanding about that arguments to unzip. Commented Oct 10, 2019 at 11:14
  • 1
    Also commenting the solution is to add -d before the target directory, as in the answer below: superuser.com/a/563232/388883 Commented Sep 23, 2022 at 18:16
56

You will also get that error if you try to unzip a whole directory of zips with a single command, like:

unzip *.zip 

I found the solution on another site.  The * symbol must be escaped, so you should run this instead:

unzip \*.zip 

instead.

7
  • oh.. looks like escape symbols arent allowed but im sure that everyone knows what those are. Commented Oct 10, 2019 at 10:22
  • 2
    This doesn’t make any sense to me, at least not if you’re talking about Unix / Linux.  (It might make sense if you’re talking about Windows, but this question is about Fedora Linux.)  And, to the extent that it does make sense (potentially), it appears to be a duplicate of sjbotha’s answer.  Can you explain what you mean more clearly? Commented Nov 15, 2019 at 5:01
  • i was talking about the unzip command that i used on a linux system. i had a directory with many zip files and i tried to extract them all with unzip *.zip and got that error because the * was not escaped. you might also be right about this not belonging here since the op just tried to extract one zip file and i was trying to extract many with one command. Commented Nov 18, 2019 at 0:23
  • 1
    This simplest answer is the best. And this is it. Thank you @dfasdfg Commented Oct 24, 2021 at 18:47
  • 1
    I don't know why the escaping is needed, but when I don't use it I get this: user@computer:/data/imputed$ unzip *.zip Archive: chr_10.zip caution: filename not matched: chr_11.zip ... works with it. Commented Apr 13, 2023 at 1:00
40

The file name argument after the archive name specifies a file to extract. Use -d to specify the target directory:

Usage: unzip [-Z] [-opts[modifiers]] file[.zip] [list] [-x xlist] [-d exdir] ... -d extract files into exdir 

Moreover, -Z is used to querying the archive, not extracting.

2
  • 1
    didn't get you. Can you please write the command Commented Mar 9, 2013 at 10:00
  • 2
    @SuhailGupta: unzip -d /opt/lampp/htdocs/joomla/ Joomla_3.0.3-Stable-Full_Package.zip, i.e. drop -Z, add -d. Commented Mar 9, 2013 at 10:04
16

This exact command worked for me:
unzip -o archive.zip -d /Users/current/Dev/tools/

Notice the combination of options -o & -d (destination/inflation path).

2
  • worked for me too. Commented Nov 28, 2019 at 21:23
  • Thanks. This worked for me as well. Commented Apr 15, 2024 at 23:06
4

Use the -d operator

unzip Joomla_3.0.3-Stable-Full_Package.zip -d /opt/lampp/htdocs/joomla

1

Trying to unzip a zipped file with a new name will raise the 'Filename not matches' exception. To workaround this move the zip file to the destination directory

mv the_file.zip somedir/ 

navigate to the destination directory

cd somedir/ 

from there run the unzip command without the destination filename argument

unzip the_file.zip 

Everything will work well.

so in this case the commands should be

[root@Feddy Joomla]# mv Joomla_3.0.3-Stable-Full_Package.zip /opt/lampp/htdocs/joomla/ [root@Feddy Joomla]# cd /opt/lampp/htdocs/joomla/ [root@Feddy Joomla]/opt/lampp/htdocs/joomla# unzip Joomla_3.0.3-Stable-Full_Package.zip 
0

From this answer:

The above error indicates that you used the unzip command wrongly. Your shell expands the command ‘unzip *.zip’ as follows:

unzip a.zip b.zip c.zip 

The solution:

unzip '*.zip' 

Doing this shell doesn’t recognize it’s a wildcard character.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.