Trying to unzip a file, 'Filename not matched' when the directory exists

33

3

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?

[root@Feddy Joomla]# 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)

Suhail Gupta

Posted 2013-03-09T08:26:40.420

Reputation: 1 655

Answers

36

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/*"

sjbotha

Posted 2013-03-09T08:26:40.420

Reputation: 677

1What's the -o flag? – Amalgovinus – 2016-10-05T22:21:24.597

1The -o option is to overwrite existing files without prompting. – sjbotha – 2016-10-06T18:29:39.370

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 – Jaymon – 2018-12-28T23:38:41.623

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. – Ernest Friedman-Hill – 2019-10-10T11:14:51.377

I had this error, found this page, and this answer solved my problem. – Derek Bennett – 2019-11-01T20:12:58.273

18

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.

choroba

Posted 2013-03-09T08:26:40.420

Reputation: 14 741

didn't get you. Can you please write the command – Suhail Gupta – 2013-03-09T10:00:08.430

1@SuhailGupta: unzip -d /opt/lampp/htdocs/joomla/ Joomla_3.0.3-Stable-Full_Package.zip, i.e. drop -Z, add -d. – choroba – 2013-03-09T10:04:25.687

4

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.

dfasdfg

Posted 2013-03-09T08:26:40.420

Reputation: 41

oh.. looks like escape symbols arent allowed but im sure that everyone knows what those are. – dfasdfg – 2019-10-10T10:22:22.993

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?

– G-Man Says 'Reinstate Monica' – 2019-11-15T05:01:15.190

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. – dfasdfg – 2019-11-18T00:23:30.687

2

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).

MusH

Posted 2013-03-09T08:26:40.420

Reputation: 21

worked for me too. – Manikandan Arunachalam – 2019-11-28T21:23:58.070

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

Tenflex

Posted 2013-03-09T08:26:40.420

Reputation: 11