{
    "mode": "man",
    "parameter": "tree",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/tree/1/json",
    "generated": "2026-05-30T05:14:16Z",
    "synopsis": "tree  [-acdfghilnpqrstuvxACDFJQNSUX]  [-L  level [-R]] [-H baseHREF] [-T title] [-o filename]\n[-P pattern] [-I pattern] [--gitignore] [--matchdirs]  [--metafirst]  [--ignore-case]  [--no‐‐\nlinks]  [--inodes]  [--device]  [--sort[=]name]  [--dirsfirst] [--filesfirst] [--filelimit #]\n[--si] [--du] [--prune] [--timefmt[=]format] [--fromfile] [--info]  [--noreport]  [--version]\n[--help] [--] [directory ...]",
    "sections": {
        "NAME": {
            "content": "tree - list contents of directories in a tree-like format.\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "tree  [-acdfghilnpqrstuvxACDFJQNSUX]  [-L  level [-R]] [-H baseHREF] [-T title] [-o filename]\n[-P pattern] [-I pattern] [--gitignore] [--matchdirs]  [--metafirst]  [--ignore-case]  [--no‐‐\nlinks]  [--inodes]  [--device]  [--sort[=]name]  [--dirsfirst] [--filesfirst] [--filelimit #]\n[--si] [--du] [--prune] [--timefmt[=]format] [--fromfile] [--info]  [--noreport]  [--version]\n[--help] [--] [directory ...]\n\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Tree  is  a  recursive  directory  listing  program that produces a depth indented listing of\nfiles, which is colorized ala dircolors if the LSCOLORS environment variable is set and out‐\nput  is  to tty.  With no arguments, tree lists the files in the current directory.  When di‐\nrectory arguments are given, tree lists all the files and/or directories found in  the  given\ndirectories  each  in turn.  Upon completion of listing all files/directories found, tree re‐\nturns the total number of files and/or directories listed.\n\nBy default, when a symbolic link is encountered, the path that the symbolic link refers to is\nprinted after the name of the link in the format:\n\nname -> real-path\n\nIf  the  `-l'  option is given and the symbolic link refers to an actual directory, then tree\nwill follow the path of the symbolic link as if it were a real directory.\n\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "Tree understands the following command line switches:\n\n",
            "subsections": []
        },
        "LISTING OPTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "-a",
                    "content": "with  a dot `.').  In no event does tree print the file system constructs `.' (current\ndirectory) and `..' (previous directory).\n",
                    "flag": "-a"
                },
                {
                    "name": "-d",
                    "content": "",
                    "flag": "-d"
                },
                {
                    "name": "-l",
                    "content": "bolic links that will result in recursion are avoided when detected.\n",
                    "flag": "-l"
                },
                {
                    "name": "-f",
                    "content": "",
                    "flag": "-f"
                },
                {
                    "name": "-x",
                    "content": "",
                    "flag": "-x"
                },
                {
                    "name": "-L",
                    "content": "Max display depth of the directory tree.\n",
                    "flag": "-L"
                },
                {
                    "name": "-R -L",
                    "content": "them execute tree again adding `-o 00Tree.html' as a new option.\n",
                    "flag": "-L"
                },
                {
                    "name": "-P",
                    "content": "List only those files that match the wild-card pattern.  You may have multiple -P  op‐\ntions.  Note: you must use the -a option to also consider those files beginning with a\ndot `.' for matching.  Valid wildcard operators are `*' (any zero or more characters),\n``  (any  zero  or more characters as well as null /'s, i.e. // may match a single\n/), `?' (any single character), `[...]' (any single character listed between  brackets\n(optional - (dash) for character range may be used: ex: [A-Z]), and `[^...]' (any sin‐\ngle character not listed in brackets) and `|' separates alternate patterns. A  '/'  at\nthe end of the pattern matches directories, but not files.\n",
                    "flag": "-P"
                },
                {
                    "name": "-I",
                    "content": "Do  not  list  those files that match the wild-card pattern.  You may have multiple -I\noptions.  See -P above for information on wildcard patterns.\n",
                    "flag": "-I"
                },
                {
                    "name": "--gitignore",
                    "content": "Uses  git  .gitignore  files  for  filtering  files  and   directories.    Also   uses\n$GITDIR/info/exclude if present.\n",
                    "long": "--gitignore"
                },
                {
                    "name": "--ignore-case",
                    "content": "If a match pattern is specified by the -P or -I option, this will cause the pattern to\nmatch without regards to the case of each letter.\n",
                    "long": "--ignore-case"
                },
                {
                    "name": "--matchdirs",
                    "content": "If a match pattern is specified by the -P option, this will cause the  pattern  to  be\napplied to directory names (in addition to filenames).  In the event of a match on the\ndirectory name, matching is disabled for the directory's contents. If the --prune  op‐\ntion is used, empty folders that match the pattern will not be pruned.\n",
                    "long": "--matchdirs"
                },
                {
                    "name": "--metafirst",
                    "content": "Print the meta-data information at the beginning of the line rather than after the in‐\ndentation lines.\n",
                    "long": "--metafirst"
                },
                {
                    "name": "--prune",
                    "content": "Makes tree prune empty directories from the output, useful when  used  in  conjunction\nwith -P or -I.  See BUGS AND NOTES below for more information on this option.\n\n--info Prints file comments found in .info files.  See .INFO FILES below for more information\non the format of .info files.\n",
                    "long": "--prune"
                },
                {
                    "name": "--noreport",
                    "content": "Omits printing of the file and directory report at the end of the tree listing.\n\n--charset charset\nSet the character set to use when outputting HTML and for line drawing.\n\n--filelimit #\nDo not descend directories that contain more than # entries.\n\n--timefmt format\nPrints (implies -D) and formats the date according to the format string which uses the\nstrftime(3) syntax.\n",
                    "long": "--noreport"
                },
                {
                    "name": "-o",
                    "content": "Send output to filename.\n",
                    "flag": "-o"
                }
            ]
        },
        "FILE OPTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "-q",
                    "content": "",
                    "flag": "-q"
                },
                {
                    "name": "-N",
                    "content": "",
                    "flag": "-N"
                },
                {
                    "name": "-Q",
                    "content": "",
                    "flag": "-Q"
                },
                {
                    "name": "-p",
                    "content": "",
                    "flag": "-p"
                },
                {
                    "name": "-u",
                    "content": "",
                    "flag": "-u"
                },
                {
                    "name": "-g",
                    "content": "",
                    "flag": "-g"
                },
                {
                    "name": "-s",
                    "content": "",
                    "flag": "-s"
                },
                {
                    "name": "-h",
                    "content": "letter for kilobytes (K), megabytes (M), gigabytes (G), terabytes (T),  petabytes  (P)\nand exabytes (E).\n\n--si   Like -h but use SI units (powers of 1000) instead.\n\n--du   For  each  directory report its size as the accumulation of sizes of all its files and\nsub-directories (and their files, and so on).  The total amount of used space is  also\ngiven  in  the  final  report (like the 'du -c' command.) This option requires tree to\nread the entire directory tree before emitting it, see BUGS AND NOTES below.   Implies\n-s.\n",
                    "flag": "-h"
                },
                {
                    "name": "-D -c",
                    "content": "time for the file listed.\n",
                    "flag": "-c"
                },
                {
                    "name": "-F",
                    "content": "`>' for doors (Solaris) and a `|' for FIFO's, as per ls -F\n",
                    "flag": "-F"
                },
                {
                    "name": "--inodes",
                    "content": "Prints the inode number of the file or directory\n",
                    "long": "--inodes"
                },
                {
                    "name": "--device",
                    "content": "Prints the device number to which the file or directory belongs\n",
                    "long": "--device"
                }
            ]
        },
        "SORTING OPTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "-v",
                    "content": "",
                    "flag": "-v"
                },
                {
                    "name": "-t",
                    "content": "",
                    "flag": "-t"
                },
                {
                    "name": "-c -D",
                    "content": "tion (if used) to print the last status change instead of modification time.\n",
                    "flag": "-D"
                },
                {
                    "name": "-U --dirsfirst",
                    "content": "",
                    "flag": "-U",
                    "long": "--dirsfirst"
                },
                {
                    "name": "-r",
                    "content": "This option is disabled when -U is used.\n",
                    "flag": "-r"
                },
                {
                    "name": "--dirsfirst",
                    "content": "List  directories before files. This is a meta-sort that alters the above sorts.  This\noption is disabled when -U is used.\n",
                    "long": "--dirsfirst"
                },
                {
                    "name": "--filesfirst",
                    "content": "List files before directories. This is a meta-sort that alters the above sorts.   This\noption is disabled when -U is used.\n\n--sort[=]type\nSort  the output by type instead of name. Possible values are: ctime (-c), mtime (-t),\nsize, or version (-v).\n\n",
                    "long": "--filesfirst"
                }
            ]
        },
        "GRAPHICS OPTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "-i",
                    "content": "-f  option.   Also  removes as much whitespace as possible when used with the -J or -x\noptions.\n",
                    "flag": "-i"
                },
                {
                    "name": "-A",
                    "content": "",
                    "flag": "-A"
                },
                {
                    "name": "-S",
                    "content": "is now equivalent to `--charset=IBM437' and may eventually be depreciated.\n",
                    "flag": "-S"
                },
                {
                    "name": "-n -C",
                    "content": "COLORFORCE if present.\n",
                    "flag": "-C"
                },
                {
                    "name": "-C",
                    "content": "TREECOLORS environment variables are not set.  Useful to colorize output to a pipe.\n",
                    "flag": "-C"
                }
            ]
        },
        "XML/JSON/HTML OPTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "-X",
                    "content": "",
                    "flag": "-X"
                },
                {
                    "name": "-J",
                    "content": "",
                    "flag": "-J"
                },
                {
                    "name": "-H",
                    "content": "Turn  on HTML output, including HTTP references. Useful for ftp sites.  baseHREF gives\nthe base ftp location when using HTML output. That is,  the  local  directory  may  be\n`/local/ftp/pub',  but  it  must  be  referenced  as  `ftp://hostname.organization.do‐\nmain/pub' (baseHREF should be `ftp://hostname.organization.domain'). Hint:  don't  use\nANSI  lines  with this option, and don't give more than one directory in the directory\nlist. If you wish to use colors via CSS style-sheet, use the -C option in addition  to\nthis option to force color output.\n",
                    "flag": "-H"
                },
                {
                    "name": "-T",
                    "content": "Sets the title and H1 header string in HTML output mode.\n",
                    "flag": "-T"
                },
                {
                    "name": "--nolinks",
                    "content": "Turns off hyperlinks in HTML output.\n",
                    "long": "--nolinks"
                }
            ]
        },
        "INPUT OPTIONS": {
            "content": "--fromfile Reads a directory listing from a file rather than the file-system.  Paths provided\non the command line are files to read from rather than directories to search.   The  dot  (.)\ndirectory indicates that tree should read paths from standard input. NOTE: this is only suit‐\nable for reading the output of a program such as find, not 'tree -fi' as symlinks cannot  (at\nleast as yet) be distinguished from files that simply contain ' -> ' as part of the filename.\n\n",
            "subsections": []
        },
        "MISC OPTIONS": {
            "content": "--help Outputs a verbose usage listing.\n",
            "subsections": [
                {
                    "name": "--version",
                    "content": "Outputs the version of tree.\n\n--     Option processing terminator.  No further options will be processed after this.\n",
                    "long": "--version"
                },
                {
                    "name": ".INFO FILES",
                    "content": ".info  files  are similiar to .gitignore files, if a .info file is found while scanning a di‐\nrectory it is read and added to a stack of .info information. Each file is composed  of  com‐\nments (lines starting with hash marks (#),) or wild-card patterns which may match a file rel‐\native to the directory the .info file is found in.  If a file should match a pattern, the tab\nindented  comment  that follows the pattern is used as the file comment.  A comment is termi‐\nnated by a non-tab indented line. Multiple patterns, each to a line, may share the same  com‐\nment.\n\n"
                }
            ]
        },
        "FILES": {
            "content": "/etc/DIRCOLORS          System color database.\n~/.dircolors             Users color database.\n.gitignore               Git exclusion file\n$GITDIR/info/exclude    Global git file exclusion list\n.info                    File comment file\n/usr/share/finfo/globalinfo  Global file comment file\n\n\n",
            "subsections": []
        },
        "ENVIRONMENT": {
            "content": "LSCOLORS      Color information created by dircolors\nTREECOLORS    Uses this for color information over LSCOLORS if it is set.\nTREECHARSET   Character set for tree to use in HTML mode.\nCLICOLOR       Enables colorization even if TREECOLORS or LSCOLORS is not set.\nCLICOLORFORCE Always enables colorization (effectively -C)\nLCCTYPE       Locale for filename output.\nLCTIME        Locale for timefmt output, see strftime(3).\nTZ             Timezone for timefmt output, see strftime(3).\nSTDDATAFD     Enable the stddata feature, optionally set descriptor to use.\n\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Steve Baker (ice@mama.indstate.edu)\nHTML output hacked by Francesc Rocher (rocher@econ.udg.es)\nCharsets and OS/2 support by Kyosuke Tokoro (NBG01720@nifty.ne.jp)\n\n",
            "subsections": []
        },
        "BUGS AND NOTES": {
            "content": "Tree  does  not prune \"empty\" directories when the -P and -I options are used by default. Use\nthe --prune option.\n\nThe -h and --si options round to the nearest whole number unlike the ls implementations which\nrounds up always.\n\nPruning  files and directories with the -I, -P and --filelimit options will lead to incorrect\nfile/directory count reports.\n\nThe --prune and --du options cause tree to accumulate the entire tree in memory before  emit‐\nting  it.  For large directory trees this can cause a significant delay in output and the use\nof large amounts of memory.\n\nThe timefmt expansion buffer is limited to a ridiculously large 255  characters.   Output  of\ntime strings longer than this will be undefined, but are guaranteed to not exceed 255 charac‐\nters.\n\nXML/JSON trees are not colored, which is a bit of a shame.\n\nProbably more.\n\nAs of version 2.0.0, in Linux, tree will attempt to automatically output a compact JSON  tree\non  file  descriptor  3  (what  I call stddata,) if present and the environment variable STD‐\nDATAFD is defined or set to a positive non-zero file descriptor value to use to  output  on.\nIt  is  hoped  that  some  day  a better Linux/Unix shell may take advantage of this feature,\nthough BSON would probably be a better format for this.\n\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "dircolors(1), ls(1), find(1), du(1), strftime(3) gitignore(5)\n\n\n\nTree 2.0.0                                                                                   TREE(1)",
            "subsections": []
        }
    },
    "summary": "tree - list contents of directories in a tree-like format.",
    "flags": [],
    "examples": [],
    "see_also": [
        {
            "name": "dircolors",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/dircolors/1/json"
        },
        {
            "name": "ls",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/ls/1/json"
        },
        {
            "name": "find",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/find/1/json"
        },
        {
            "name": "du",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/du/1/json"
        },
        {
            "name": "strftime",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/strftime/3/json"
        },
        {
            "name": "gitignore",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/gitignore/5/json"
        }
    ]
}