To the zip file format, things are not "recursive". In there, there's simply a list of files, whose names contain slashes (or more generally, path separators).
So, there's really 15 entries "flat" in your zip: the 15 "leaf" directories. The directories above are implied, since they are part of the path of these.
So, to find all top-level directories, you have to go through all entries, and extract the first path component, and then remove duplicates.
zipinfo -1 | sed -n 's;\([^/]*\)/.*;\1;p' | sort -u
Couple of things to note
- I don't know how zipinfo behaves when there's file names with line breaks in there
- if you're shifting around files between machines, where you need things like permissions, sparsity, ownership… zip is not the right tool, as it can't do these things. Also, with tools like
mksquashfs
, you can just make archives that compress usually better, and can be directly mounted using udisksctl loop-setup -f archive.squashfs
(and if necessary udisksctl mount /dev/loopN
after) or just mkdir mntdir; sudo mount -o loop archive.squashfs mountdir
, and then you can just use your usual file management (from ls
to your favorite file browser) to inspect the contents at near-zero cost.
/
after the match group\(…\)
– Marcus Müller Jun 10 '23 at 23:06zipinfo
renders newlines as^J
same as with literal^J
. Usebsdtar -tf file.zip
for a non-ambiguous output where newline is rendered as\n
and backslash as\\
.bsdtar -tf file.zip | LC_ALL=C sed -n 's;/.*;;p' | LC_ALL=C sort -u
– Stéphane Chazelas Jun 11 '23 at 06:08