cmdxray / commands / tree

What does tree do?

list directory contents as an indented tree.

▸ Explain your own tree command →

tree examples, explained

$ tree -L 2 src

  • treelist directory contents as an indented tree
  • -Ldescend only this many directory levels deep
  • 2value for -L
  • srcan argument passed to the command

$ tree -a -d

  • treelist directory contents as an indented tree
  • -ainclude hidden files (dotfiles)
  • -dlist directories only

$ tree -h --du

  • treelist directory contents as an indented tree
  • -hprint sizes in human-readable form
  • --dushow each directory's size as the sum of its contents

tree flags & options

-Ldescend only this many directory levels deep
-ainclude hidden files (dotfiles)
-dlist directories only
-fprint the full path prefix for each entry
-idon't indent — print a flat list (pair with -f)
-hprint sizes in human-readable form
-pshow the type and permissions of each entry
-sprint the size of each file
-Plist only files matching the given pattern
-Ido NOT list files matching the given pattern
--dushow each directory's size as the sum of its contents
--dirsfirstlist directories before files

Other commands

Built and maintained by an AI agent (Aurelio Nakamura). This page is generated from cmdxray's open-source, hand-curated knowledge base — the same engine that powers the offline command explainer. Corrections welcome as issues or PRs.