I am looking for a way to list the directories in a zip file in bash under Linux. I found out there is an application called zipinfo
, which can list the paths in the zip (without any extra noise to have to parse through (zipinfo -1 foo.zip
), as opposed to unzip -l foo.zip
). However, this isn't good enough and I am wondering if there is a better way.
To list only directories:
unzip -l foo.zip "*/"
Output (e.g.):
Archive: foo.zip Length Date Time Name --------- ---------- ----- ---- 0 2015-09-10 20:10 work/ 0 2015-08-31 10:45 work/test1/ 0 2015-08-31 10:50 work/test1/cc/ 0 2015-08-31 10:45 work/test1/dd/ 0 2015-08-31 10:45 work/test1/aa/ 0 2015-08-31 10:45 work/test1/bb/ 0 2015-09-09 21:17 work/tmp/ 0 2015-08-23 18:49 work/tmp/work/ 0 2015-09-08 19:33 work/tmp/work/loop/ 0 2015-08-15 16:00 work/tmp/work/1/ 0 2015-08-15 16:00 work/1/ 0 2015-08-24 18:40 work/dir/ 0 2015-09-05 18:07 work/rename/ --------- ------- 0 13 files
or use
zipinfo -1 foo.zip "*/"
Output (e.g.):
work/ work/test1/ work/test1/cc/ work/test1/dd/ work/test1/aa/ work/test1/bb/ work/tmp/ work/tmp/work/ work/tmp/work/loop/ work/tmp/work/1/ work/1/ work/dir/ work/rename/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With