Lo strumento open source Zip_Dir_List elencherà tutte le directory per te, anche per gli archivi Zip che non hanno voci di directory esplicite. Dal collegamento, vai al repository e segui le istruzioni di compilazione in readme.txt .
Per elencare solo le directory:
unzip -l foo.zip "*/"
Uscita (ad es.):
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
o usa
zipinfo -1 foo.zip "*/"
Uscita (ad es.):
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/
Su Cygwin
Non sono riuscito a far funzionare nessuno di questi sul mio Cygwin. Per il mio uso immediato, dove avevo solo bisogno di ottenere una directory profonda:
zipinfo -1 foo.zip | grep -o "^[^/]\+[/]" | sort -u
Per altre directory, puoi usare xargs
in combinazione con qualche altra cosa di analisi, qualcosa come:
## PSEUDOCODE
$ zipinfo -1 foo.zip | \
# from the pipe, run
xargs \
# do something like the following while loop, going one file at a time
while there is still a '/' in the line; do
parse off "[^/]+([/]|)$" from the line
print out the new line
done | \
sort -u
Informazioni di sistema
$ uname -a
CYGWIN_NT-10.0 C-D-ENG-E-INT3 2.11.2(0.329/5/3) 2018-11-08 14:34 x86_64 Cygwin
$ bash --version
GNU bash, version 4.4.12(3)-release (x86_64-unknown-cygwin)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ systeminfo | sed -n 's/^OS\ *//p'
Name: Microsoft Windows 10 Enterprise
Version: 10.0.17134 N/A Build 17134
Manufacturer: Microsoft Corporation
Configuration: Member Workstation
Build Type: Multiprocessor Free
$
Puoi provare a piping unzip -l
a awk
come questo:
unzip -l foo.zip | awk '/\/$/ { print $NF }'
Tutte le directory nel file unzip -l
l'output termina con una barra e $NF
stampa solo il percorso della directory.