29

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)

33

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/*"
  • 1
    What's the -o flag? – Amalgovinus Oct 5 '16 at 22:21
  • 1
    The -o option is to overwrite existing files without prompting. – sjbotha Oct 6 '16 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 – Jaymon Dec 28 '18 at 23:38
11

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.

  • didn't get you. Can you please write the command – Suhail Gupta Mar 9 '13 at 10:00
  • 1
    @SuhailGupta: unzip -d /opt/lampp/htdocs/joomla/ Joomla_3.0.3-Stable-Full_Package.zip, i.e. drop -Z, add -d. – choroba Mar 9 '13 at 10:04
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

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.