LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-08-2018, 10:43 AM   #1
thomwblair
LQ Newbie
 
Registered: Oct 2018
Location: Richmond, VA USA
Posts: 9

Rep: Reputation: Disabled
How do I list contents of all zip files in a directory?


I have a directory with many zip files with names like [B-18] Small Comms Console.zip. In the past, I have used this for one file at a time:
Code:
unzip -l HelloWorld.zip
But how can I list contents for multiple zip files with names with spaces in them and other characters like square brackets?

Last edited by thomwblair; 10-08-2018 at 10:48 AM. Reason: clarification
 
Old 10-08-2018, 10:59 AM   #2
l0f4r0
Member
 
Registered: Jul 2018
Location: Paris
Distribution: Debian
Posts: 854

Rep: Reputation: 286Reputation: 286Reputation: 286
Code:
unzip -l *.zip
doesn't do the job?

Last edited by l0f4r0; 10-08-2018 at 11:01 AM.
 
Old 10-08-2018, 11:01 AM   #3
thomwblair
LQ Newbie
 
Registered: Oct 2018
Location: Richmond, VA USA
Posts: 9

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by l0f4r0 View Post
Code:
unzip -l *.zip
doesn't do the job?
No, but unzip -l "*.zip" does work! Thank you!

Last edited by thomwblair; 10-08-2018 at 11:02 AM.
 
Old 10-08-2018, 11:03 AM   #4
nodir
Member
 
Registered: May 2016
Posts: 222

Rep: Reputation: Disabled
If all those files in one directory, then you will make use of a glob.
Something like
Code:
unzip -l ./*.zip
. being the current working directory, * expanding to everything before .zip

details may be very important when it comes to globs, so here is a correct explanation:
http://mywiki.wooledge.org/glob
 
Old 10-08-2018, 11:07 AM   #5
l0f4r0
Member
 
Registered: Jul 2018
Location: Paris
Distribution: Debian
Posts: 854

Rep: Reputation: 286Reputation: 286Reputation: 286
Quote:
Originally Posted by thomwblair View Post
No, but unzip -l "*.zip" does work! Thank you!
Out of curiosity, what doesn't work with unzip -l *.zip please? What is the error output?
 
Old 10-08-2018, 11:09 AM   #6
thomwblair
LQ Newbie
 
Registered: Oct 2018
Location: Richmond, VA USA
Posts: 9

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by l0f4r0 View Post
Out of curiosity, what doesn't work with unzip -l *.zip please? What is the error output?
Here is the error output:
Code:
Archive:  [B-18] Minions.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
---------                     -------
        0                     0 files

1 archive had fatal errors.
So, it only tried to do the first zip file and then had a fatal error.

Last edited by thomwblair; 10-08-2018 at 11:12 AM.
 
Old 10-08-2018, 11:20 AM   #7
l0f4r0
Member
 
Registered: Jul 2018
Location: Paris
Distribution: Debian
Posts: 854

Rep: Reputation: 286Reputation: 286Reputation: 286
Quote:
Originally Posted by thomwblair View Post
Here is the error output:
Code:
Archive:  [B-18] Minions.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
---------                     -------
        0                     0 files

1 archive had fatal errors.
So, it only tried to do the first zip file and then had a fatal error.
Ok I got it.
The problem is not about the fatal error but about the * expansion by the shell.
The correct command is:
Code:
unzip -l \*.zip
Does it work now with that?
 
Old 10-08-2018, 11:25 AM   #8
thomwblair
LQ Newbie
 
Registered: Oct 2018
Location: Richmond, VA USA
Posts: 9

Original Poster
Rep: Reputation: Disabled
Yes, unzip -l \*.zip does work as well. Thank you!
 
  


Reply

Tags
list, osx, terminal


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How can I have zip -d file.zip "__MACOSX*" work on all zip files in directory? thomwblair Linux - Newbie 10 10-08-2018 02:30 PM
Using zip to zip the contents of a directory to another? Paradigm6790 Linux - Newbie 2 07-25-2012 11:51 AM
[SOLVED] List files/directory names without directory contents? littlebigman Linux - Software 2 05-03-2011 04:42 AM
zip -x for a directory - Subfolder contents not being excluded recursively? SirTristan Linux - Newbie 4 12-10-2010 03:52 AM
list contents of directory without listing contents baddah Linux - Newbie 2 06-12-2006 04:02 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration