A collection of computer systems and programming tips that you may find useful.
 
Brought to you by Craic Computing LLC, a bioinformatics consulting company.

Wednesday, August 10, 2011

Unzipping multiple zip files on Unix

To unzip multiple .zip files with one command command on a UNIX system the obvious command to try is 'unzip *.zip' - but that doesn't work...

$ unzip *zip
Archive: ipab20080103_wk01.zip
caution: filename not matched: ipab20080110_wk02.zip
caution: filename not matched: ipab20080117_wk03.zip
[...]


UNIX is expanding the wildcard and passing that string to unzip, which thinks that you are asking for specific files from the zip archive given as the first argument.

You need to escape the wildcard with a backslash so that 'unzip' sees it and expands it correctly.

$ unzip \*.zip
Archive: ipab20080103_wk01.zip
inflating: ipab20080103.xml
inflating: ipab20080103lst.txt
inflating: ipab20080103rpt.html

Archive: ipab20080110_wk02.zip
inflating: ipab20080110.xml
inflating: ipab20080110lst.txt
inflating: ipab20080110rpt.html
[...]


Glad I stumbled on that - saves me a lot of time...


No comments: