List contents of tarball in tree format
Several scripts exist for converting a list of path names into tree form:
- my own treeify.pl
- treeify.rs by Loïc Damien
- treeify.py by Hakril
All these scripts work with tar -tf …
output; for example:
$ tar -tf foo.tar | treeify foo ├─bar │ ├─myfile.txt │ └─yourfile.txt └─baz └─qux └─hisfile.txt
Also:
$ bsdtar -tf foo.zip | treeify
$ find /dir -size +5 | treeify
$ git ls-files | treeify
$ pacman -Qql foopkg | treeify
$ unrar vb foo.rar | treeify
$ zipinfo -1 foo.zip | treeify
$ gsettings list-schemas | treeify -s. -f
$ qdbus | sed -n "s/^ //p" | treeify -s. -f
$ ldns-walk netbsd.org | awk '{print $1}' | treeify -s. -f -R
This is just an addendum to user1686's answer though I do not have enough reputation to comment. While his scripts certainly do the job well they need to be downloaded while tree
can actually do this natively:
$ tar tf foo.tar | tree --fromfile .
.
└── foo
├── bar
│ ├── myfile.txt
│ └── yourfile.txt
└── baz
└── qux
└── hisfile.txt
4 directories, 3 files
Note that unlike most tools tree
uses a dot .
and not a dash -
to read input from stdin:
INPUT OPTIONS
--fromfile
Reads a directory listing from a file rather than the file-system.
Paths provided on the command line are files to read from rather than directories to search.
The dot (.) directory indicates that tree should read paths from standard input.
This allows one to use the typical tree functions like wildcards though sizes obviously cannot be shown and the level argument (-L
) apparently also does not work...