Printing the directory tree
Graphically representing directories and filesystems as a tree hierarchy makes them easier to visualize. This representation is used by monitoring scripts to present the filesystem in an easy-to-read format.
Getting ready
The tree command prints graphical trees of files and directories. The tree command does not come with preinstalled Linux distributions. You must install it using the package manager.
How to do it...
The following is a sample Unix filesystem tree to show an example:
$ tree ~/unixfs unixfs/ |-- bin | |-- cat | `-- ls |-- etc | `-- passwd |-- home | |-- pactpub | | |-- automate.sh | | `-- schedule | `-- slynux |-- opt |-- tmp `-- usr 8 directories, 5 files
The tree command supports several options:
- To display only files that match a pattern, use the
-Poption:
$ tree path -P PATTERN # Pattern should be wildcard in single
quotesConsider this example:
$ tree PATH -P '*...