Display the Linux directory tree with the tree command
The Linux tree command allows to display a directory tree on the command line. If the environment variable LS_COLORS is set, the textual representation is displayed in different colours. At the end of the output, the total number of files and directories is output in the searched folder.
Installation
Under Ubuntu and Debian, the installation can be made with the following command:
apt-get install tree
Under CentOS/RHEL, the command can be installed as follows:
yum install tree
Example of a "tree"-output
$ tree vector/
vector/
├── csshover.htc
├── csshover.min.htc
├── images
│ ├── arrow-down-focus-icon.png
│ ├── arrow-down-icon.png
│ ├── audio-icon.png
│ ├── bullet-icon.png
│ ├── document-icon.png
│ ├── edit-icon.png
│ ├── external-link-ltr-icon.png
│ ├── external-link-rtl-icon.png
│ ├── file-icon.png
│ ├── link-icon.png
│ ├── lock-icon.png
│ ├── magnify-clip.png
│ ├── mail-icon.png
│ ├── news-icon.png
│ ├── page-fade.png
│ ├── portal-break-ltr.png
│ ├── portal-break.png
│ ├── portal-break-rtl.png
│ ├── preferences-break.png
│ ├── preferences-fade.png
│ ├── search-fade.png
│ ├── search-ltr.png
│ ├── search-rtl.png
│ ├── tab-break.png
│ ├── tab-current-fade.png
│ ├── tab-normal-fade.png
│ ├── talk-icon.png
│ ├── user-icon.png
│ ├── video-icon.png
│ ├── watch-icon-loading.gif
│ └── watch-icons.png
├── screen.css
├── screen-hd.css
└── vector.js
1 directory, 36 filesAlternatives
If the tree command is not installed, the following combination of find and sed, for example, can be used as an alternative (see also [1])
$ ls -R vector | grep ':$' | sed -e 's/:$//' -e 's/[^\/]*\//| /g' -e 's/| \([^|]\)/`--\1/g'
vector
|___csshover.htc
|___csshover.min.htc
|___images
| |___arrow-down-focus-icon.png
| |___arrow-down-icon.png
| |___audio-icon.png
| |___bullet-icon.png
| |___document-icon.png
| |___edit-icon.png
| |___external-link-ltr-icon.png
| |___external-link-rtl-icon.png
| |___file-icon.png
| |___link-icon.png
| |___lock-icon.png
| |___magnify-clip.png
| |___mail-icon.png
| |___news-icon.png
| |___page-fade.png
| |___portal-break-ltr.png
| |___portal-break.png
| |___portal-break-rtl.png
| |___preferences-break.png
| |___preferences-fade.png
| |___search-fade.png
| |___search-ltr.png
| |___search-rtl.png
| |___tab-break.png
| |___tab-current-fade.png
| |___tab-normal-fade.png
| |___talk-icon.png
| |___user-icon.png
| |___video-icon.png
| |___watch-icon-loading.gif
| |___watch-icons.png
|___screen.css
|___screen-hd.css
|___vector.js
|
Author: Christoph Mitasch Christoph Mitasch works in the Web Operations & Knowledge Transfer team at Thomas-Krenn. He is responsible for the maintenance and further development of the webshop infrastructure. After an internship at IBM Linz, he finished his diploma studies "Computer- and Media-Security" at FH Hagenberg. He lives near Linz and beside working, he is an enthusiastic marathon runner and juggler, where he hold various world-records.
|
|
Translator: Alina Ranzinger Alina has been working at Thomas-Krenn.AG since 2024. After her training as multilingual business assistant, she got her job as assistant of the Product Management and is responsible for the translation of texts and for the organisation of the department.
|


