NAME
dtree
—
Command line program to draw
trees
SYNOPSIS
dtree |
[-hVv ] |
dtree |
[-s set]
[file] |
DESCRIPTION
dtree
is a simple command line program
which reads a number of lines and formats them as a tree using line drawing
characters in several sets. Each input line represents one node in a tree.
The number of tabs at the start of each input line determines the nesting
level of that node. It is intended for the root node to have no tabs at the
start.
If the file is omitted,
dtree
will read from stdin. Any additional arguments
after file will be ignored.
-h
- Prints usage information.
-s
set- Selects the symbol set set. Allowed values for
set are:
a
(ASCII set),d
(double-stroke set), ands
(single-stroke set, default). -V
- Prints full version information: like
-v
, followed by copyright notice. -v
- Prints version and commit date.
EXIT STATUS
The dtree
utility exits 0 on
success, and >0 if an error occurs.
EXAMPLES
Format a tree using double-stroke box drawing characters:
printf
"A\n\tB\n\t\tC\n\tD\n" | dtree -sd
tree(1) replacement:
find . -print | sed -E
"s,[^/]+/,$(printf '\t'),g" | dtree
same, using ASCII characters:
find . -print | sed -E
"s,[^/]+/,$(printf '\t'),g" | dtree -sa
poor man's findmnt(1) (depends on having /proc/mounts active):
LC_ALL=C sort -k2 /proc/mounts | awk '{ # pp = previous pointer sl = $2; gsub("[^/]", "", sl); slashc = length(sl); # slash count if ($2 != "/" && slashc > prevsc[pp] && substr($2,0,length(prev[pp])) == prev[pp]) { for (i = 0; i < pp+1; i++) printf "\t"; pp++; } else if ($2 != "/") { if (slashc < prevsc[pp] && substr($2,0,length(prev[pp-1])) != prev[pp-1]) pp--; for (i = 0; i < pp; i++) printf "\t"; } print $2; prev[pp] = $2; # previous mountpoint prevsc[pp] = slashc; # previous slash count }' | dtree
SEE ALSO
AUTHORS
Strahinya Radich ⟨sr@strahinja.org⟩, 2023-2024