Ahh, the shell gets such disrespect nowadays. With all the GUI filesystem browsers available now, "tree" may not even be installed on your Linux box anymore. Well, you can fix that with a "yum install tree" or something like it. I couldn't get it on a recent RedHat system with "up2date" (though it's in Fedora, presently relegated to the "less popular" disk 4 on FC2).
Tree is functionally similar to "find ." or "ls -R", but with differently formatted output. It accepts many of the same arguments as "ls", and produces the expected results. It also has some of the level and device control of "find" - if you ever find yourself piping find to ls, it may be that "tree" is just what you want.
An interesting and unexpected ability is that it can produce html output with its -H flag. There's also its "-P" flag, which lets you specify wildcards:
# tree -p -P "*.html" . |-- [drwxr-xr-x] appl |-- [drwxr-xr-x] fred | `-- [-rw-r--r--] a.html `-- [drwxr-xr-x] zoo 3 directories, 1 file
Got something to add? Send me email.
More Articles by Tony Lawrence © 2012-07-17 Tony Lawrence
As an experimental psychologist, I have been trained not to believe anything unless it can be demonstrated in the laboratory on rats or sophomores. (Steven Pinker)
Printer Friendly Version
tree Copyright © April 2005 Tony Lawrence
Have you tried Searching this site?
This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.
Contact us
Printer Friendly Version