Date:

Share:

Unzipping multiple files from the command-line by Josh Sherman

Related Articles

I ran into a problem recently where I tried to open a file directory, but the “Extract” and “Extract to” options stopped showing up in the GNOME Files app. Before realizing that the problem was due to having a non-ZIP archive in the directory I selected, I switched to the command line to do the job.

Well, sort of. Not at first at least.

My first thought was to just run:

What didn’t do what I 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 stand for unzip Very much made it look like it should have worked. It supports * wildcard, as long as it is part of the file name and not the path.

Think maybe it was something weird zshI tried it bash and faced the same results.

Luckily, there’s a nice little trick to get things moving. Simply throwing 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

good things? want more?

Weekly emails about technology, development and sometimes sauerkraut.

100% Fresh, Grade A Content, Never Spam.

Source

Popular Articles