Unzipping multiple files from the command-line

Josh Sherman
1 min read
Command-line Interface

Ran into an issue recently where I attempting to unzip a directory of files, but the “Extract” and “Extract to” options stopped showing up in the GNOME Files app. Before realizing that the issue was due to there being a non-ZIP archive in the directory that I had selected, I took to the command-line to get the job done.

Well, at quite. Not at first at least.

My first thought was to simply run:

$ unzip *.zip

Which did not do what I had expected:

$ unzip *.zip
Archive:  first.zip
caution: filename not matched:  second.zip
caution: filename not matched:  third.zip
caution: filename not matched:  etc.zip
# ...
caution: filename not matched:  last.zip

Interestingly enough, the man page for unzip very much made it seem like this should have worked. It supports the * wildcard character, as long as it’s part of the filename and not the path.

Thinking maybe it was some weird thing in zsh, I gave it a shot in bash and was faced with the same results.

Fortunately, there’s a nice little trick that will get things moving. Simply tossing single quotes around the filename (with the wildcard) will get things moving in the right direction:

$ unzip '*.zip'
Archive:  first.zip
  inflating: first.txt

Archive:  second.zip
  inflating: second.txt

Archive:  third.zip
  inflating: third.txt

Archive:  last.zip
  inflating: last.txt

# ...

Archive:  last.zip
  inflating: last.txt
Join the Conversation

Good stuff? Want more?

Weekly emails about technology, development, and sometimes sauerkraut.

100% Fresh, Grade A Content, Never Spam.

About Josh

Husband. Father. Pug dad. Musician. Founder of Holiday API, Head of Engineering and Emoji Specialist at Mailshake, and author of the best damn Lorem Ipsum Library for PHP.

Currently Reading

Parasie Eve

Previous Reads

Buy Me a Coffee Become a Sponsor

Related Articles