On Fri, Feb 20, 2026 at 06:10:53 -0800, Chime Hart wrote:
> Well Nicolas, when I ran 
> unzip *.zip
> it only handled the first file, unlike unp which handled all zip files.

That's because of how the unzip command's syntax is constructed, and
how the shell handles wildcards.

The first and most important thing is that the SHELL is expanding
that wildcard, because you didn't quote it.  If you have two .zip
files in the current directory, then your command expands to

    unzip file1.zip file2.zip

Next, we look at the synopsis for unzip:

hobbit:~$ unzip
UnZip 6.00 of 20 April 2009, by Debian. Original by Info-ZIP.

Usage: unzip [-Z] [-opts[modifiers]] file[.zip] [list] [-x xlist] [-d exdir]
  Default action is to extract files in list, except those in xlist, to exdir;
  file[.zip] may be a wildcard.  -Z => ZipInfo mode ("unzip -Z" for usage).

The syntax only allows a single zip file to be specified.  Any other
filenames that follow it are part of the "list", which is the set of
filenames (or patterns) to be extracted.  Therefore, your command has
the following semantics:

    Extract from the archive "file1.zip"
    Limit extraction to the file(s) named "file2.zip"

You'll find that tar works the same way -- you can only specify a single
archive to extract, but multiple file-matching patterns to extract from
that single archive.

If you want to give a pattern to unzip, or tar, or find, or mmv, or any
other command that handles file-matching patterns on its own, then you
must quote the pattern to avoid having the shell expand it.

    unzip file.zip *.txt    # wrong
    unzip file.zip '*.txt'  # right

Remember also, the three forms of quoting in Bourne shells are single
quotes, double quotes, and backslashes.  In this context, any of those
three will work.

    unzip file.zip "*.txt"  # also right
    unzip file.zip \*.txt   # also right

Reply via email to