DTREE(1) General Commands Manual DTREE(1)

dtreeCommand line program to draw trees

dtree [-hVv]


dtree [-s set] [file]

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.

Prints usage information.
set
Selects the symbol set set. Allowed values for set are: a (ASCII set), d (double-stroke set), and s (single-stroke set, default).
Prints full version information: like -v, followed by copyright notice.
Prints version and commit date.

The dtree utility exits 0 on success, and >0 if an error occurs.

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 '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.

tree(1)

Strahinya Radich ⟨sr@strahinja.org⟩, 2023-2025

September 23, 2025 OpenBSD 7.7