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.
-sset- 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 -sdtree(1) replacement:
find . -print | sed -E
"s,[^/]+/,$(printf '\t'),g" | dtreesame, using ASCII characters:
find . -print | sed -E
"s,[^/]+/,$(printf '\t'),g" | dtree -sapoor man's findmnt(1) (depends on having /proc/mounts active):
LC_ALL=C sort -k2 /proc/mounts |
awk 'BEGIN{ pp=0 } { # pp = previous pointer
sl = $2;
gsub("[^/]", "", sl);
slashc = length(sl); # slash count
if ($2 != "/" &&
substr($2,0,length(prev[pp])) == prev[pp])
{
if (prev[pp] == "/" || slashc > prevsc[pp])
pp++;
for (i = 0; i < pp; i++)
printf "\t";
prev[pp] = $2; # previous mountpoint
prevsc[pp] = slashc; # previous slash count
}
else if ($2 != "/")
{
if (slashc < prevsc[pp] &&
substr($2,0,length(prev[pp-1])) != prev[pp-1])
pp--;
prev[pp] = $2;
prevsc[pp] = slashc;
for (i = 0; i < pp; i++)
printf "\t";
}
else
{
prev[pp] = $2;
prevsc[pp] = slashc;
}
print $2;
}' |
dtree
On OpenBSD, replace the first command in the above pipeline with
mount |
and the parameter $2 with $3.
SEE ALSO
AUTHORS
Strahinya Radich ⟨sr@strahinja.org⟩, 2023-2025