Trying to unzip a file, 'Filename not matched' when the directory exists
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:
(The joomla directory is empty)
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/*"
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.
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.
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).