Linux: View Directory as Tree
View Directory as Tree
The command tree
prints a dir in a visual tree format.
to install:
sudo apt-get install tree
Tree view is useful, for example:
- Get overview of the dir structure of a large project.
- You need to organize your files and see each's file size.
Useful Options
Here's some of the most useful options.
-f
- Show full path.
-L level
- Specify depth.
-P pattern
-
Using wildcard to match file names to limit listing. For example,
-P '*html'
to show only html files. Note: this will still show directories even if it doesn't contain matching file. -d
- Show dirs only.
-r
- Reverse order.
-t
- Sort output by last modification time.
--dirsfirst
- List dir before files.
--filelimit n
- Don't go into dir that's more than n files.
-F
- Display file type indicator. For example, “/” for dir, “*” for executable, etc.
-p
- Show file perm and type.
-h
- Print file size in human readable format.
See man tree
for more options.
Linux, Files and Dirs
- Linux: Navigate Directory
- Linux: List Files
- Linux: Walk Dir: find, xargs
- Linux: View Directory as Tree
- Linux: Copy File
- Linux: Move / Rename, File / Dir
- Linux: Create New File
- Linux: Create New Dir
- Linux: Delete File/Dir
- Linux: Show Directory Size: du
- Linux: Show Difference Between Directories
- Linux: rsync Tutorial