tags:

views:

131

answers:

5

Hi, I got a directory of ZIP files (created on a Windows machine), I can manually unzip them using "unzip filename" but how can I unzip all the ZIP files in the current folder via a shell scripts?

Using Unbuntu Linux Server.

Thanks

A: 

try:

unzip *.zip
Andrey
Yeah, unzip supports wildcards, no need for anything fancy.
Chad Birch
the correct invocation is unzip \\*.zip
fuzzy lollipop
-1 doesn't work
sfussenegger
This is incorrect.
geocar
why \\*.zip? i am unable to test it, sorry
Andrey
The shell expands the wildcard to `unzip foo.zip bar.zip` which isn't correct as unzip expects a list of files from the archive after the first argument. Adding a `\` avoids this wildcard expansion. Unzip than handles expansion internally. So actually, @Chad was right with "unzip supports wildcards" but wrong with "no need for anything fancy" ;)
sfussenegger
should have been: Adding a '\'
sfussenegger
thanks for great explanation, this is much better then silent minuses! i thought unzip can have multiples targets, like unzip foo.zip bar.zip.
Andrey
it wasn't a silent minus, I gave a comment with the correct invocation
fuzzy lollipop
A: 
for i in `ls *.zip`; do unzip $i; done
Dominik
Useless use of `\`ls\``. `for i in *.zip; do ...; done`
ephemient
*Dangerous* use of ls. What if you have a file called "-j -o -d .. jackass.zip"
geocar
+4  A: 

(untested) but this link suggests:

unzip \*.zip

ChristopheD
+1  A: 

unzip *.zip, or if they are in subfolders, then something like

find . -name "*.zip" -exec unzip {} \;
phatmanace
unzip does wildcard processing so a file called "*.zip" won't do what you expect.
geocar
+1  A: 

just put in some quotes to escape the wildcard

unzip "*.zip"
ghostdog74