snippetbashTip
tree — Show the contents of the current directory as a tree. More information: <https://manned.org/tree>.
Viewed 0 times
thecurrentcommandtreecontentsshowcli
Problem
How to use the
tree command: Show the contents of the current directory as a tree. More information: <https://manned.org/tree>.Solution
tree — Show the contents of the current directory as a tree. More information: <https://manned.org/tree>.Print files and directories up to
num levels of depth (where 1 means the current directory):tree -L {{num}}Print directories only:
tree -dPrint hidden files too with colorization on:
tree -a -CPrint the tree without indentation lines, showing the full path instead (use
-N to not escape non-printable characters):tree -i -fPrint the size of each file and the cumulative size of each directory, in human-readable format:
tree -s -h --duPrint files within the tree hierarchy, using a wildcard (glob) pattern, and pruning out directories that don't contain matching files:
tree -P '{{*.txt}}' --prunePrint directories within the tree hierarchy, using the wildcard (glob) pattern, and pruning out directories that aren't ancestors of the wanted one:
tree -P {{directory_name}} --matchdirs --prunePrint the tree ignoring the given directories:
tree -I '{{directory_name1|directory_name2}}'Code Snippets
Print files and directories up to `num` levels of depth (where 1 means the current directory)
tree -L {{num}}Print directories only
tree -dPrint hidden files too with colorization on
tree -a -CPrint the tree without indentation lines, showing the full path instead (use `-N` to not escape non-printable characters)
tree -i -fPrint the size of each file and the cumulative size of each directory, in human-readable format
tree -s -h --duContext
tldr-pages: common/tree
Revisions (0)
No revisions yet.