Quick hack:
#!/bin/sh 7z l "$" |\ tail -n +17 |\ sed 's/.\//' |\ tac |\ awk 'NR>2 { n=split($6, a, "/") print a[n] }'
Save as 7ztree
, use as
$ 7ztree archive.7z jsloader resource gre modules NetworkHelper.jsm CommonDialog.jsm jsdebugger.jsm CertUtils.jsm DownloadPaths.jsm FileUtils.jsm source-editor-textarea.jsm
tail
is used to strip irrelevant information.17
here,53
forsed
and2
forawk
were the correct magic numbers on my 7-zip version at least.sed
will strip the first magic 53 characters (this is to better the handling of spaces inawk
).tac
is used to reverse input (otherwise the tree would be upside down the way 7z presents the listing).
It is straight forward, but quirky, to add logic to get the same fancy output as tree
has.
awk
could be used to filter and reverse lines in a single command instead of tail
and tac
, but it would be a bit more convoluted.
EDIT: Added sed
to better handle spaces. And on that note, a pure sed
version with the same output as the above script in its current form:
#!/bin/sh 7zr l ../testing.7z |\ tail -n +17 |\ tac |\ tail -n +3 |\ sed 's/.\//; s#[^/]*/# #g'
but this will not be easy to get nicer output from.
EDIT2: And some Perl golf! :-D
#!/usr/bin/perl my @lines; my $i=0; while(<>) for my $i (reverse 0..$#lines-2)
If one adds some line breaks in that, it is probably the easiest way to build nice output formatting.