Apr 12, 2017

[HDGEM] How to Unzip Multiple Files from Linux Command Line

$ unzip *.zip
Archive:  MySQL-Enterprise-Monitor-Agent3.3.3.zip
caution: filename not matched:  MySQL-Enterprise-Monitor-Proxy-and-Aggregator3.3.3 .zip
caution: filename not matched:  MySQL-Enterprise-Monitor-Service-Manager3.3.3.zip

$ unzip '*.zip'
Archive:  MySQL-Enterprise-Monitor-Agent3.3.3.zip
  inflating: mysqlmonitoragent-3.3.3.1199-linux-x86-64bit-update-installer.bin  
  inflating: mysqlmonitoragent-3.3.3.1199-linux-x86-64bit-installer.bin  
  inflating: monitor.pdf             
  inflating: README_en.txt           
  inflating: monitor.a4.pdf          
  inflating: mysql-monitor-html.tar.gz  
 extracting: mysql-monitor-html.zip  
  inflating: READ_ME_ja.txt          

Archive:  MySQL-Enterprise-Monitor-Service-Manager3.3.3.zip
  inflating: mysqlmonitor-3.3.3.1199-linux-x86_64-installer.bin  
  inflating: mysqlmonitor-3.3.3.1199-linux-x86_64-update-installer.bin  
replace monitor.pdf? [y]es, [n]o, [A]ll, [N]one, [r]ename: A
  inflating: monitor.pdf             
  inflating: README_en.txt           
  inflating: monitor.a4.pdf          
  inflating: mysql-monitor-html.tar.gz  
 extracting: mysql-monitor-html.zip  
  inflating: READ_ME_ja.txt          

Archive:  MySQL-Enterprise-Monitor-Proxy-and-Aggregator3.3.3 .zip
  inflating: mysqlmonitoraggregator-3.3.3.1199-linux-x86-64bit-installer.bin  
  inflating: mysqlmonitoraggregator-3.3.3.1199-linux-x86-64bit-update-installer.bin  
  inflating: README.txt              
  inflating: monitor.pdf             
  inflating: monitor.a4.pdf          
  inflating: mysql-monitor-html.tar.gz  
 extracting: mysql-monitor-html.zip  

3 archives were successfully processed.

Explanation:
Whenever you use a wildcard (*), the shell itself will expand that and pass the results to the program rather than the program handling the expansion itself.

unzip *.zip becomes 
unzip file1.zip file2.zip
which unzip doesn't support.

Quoting the argument to prevent the shell from interpreting it:
'*.zip'


--
Posted By Blogger to HDGEM at 4/12/2017 06:48:00 AM