linux: view dir as tree
Perm URL with updates: http://xahlee.info/linux/linux_view_dir_as_tree.html
you can view directory as a
tree. It prints a dir in a visual tree format, similar to
pstree for processes.
sudo apt-get install tree
For example, here's a tree view of 〔/etc/X11〕 dir.
Tree view is extremely useful, for example:
- When you are working on a project new to you, you have a directory, with hundreds of files, and you need to get a overview of the structure.
- You need to organize your files and see each's file size.
Here's some of the most useful options.
-L ‹level›→ specify depth.
-P ‹pattern›→ using wildcard to match file names to limit listing. ⁖
*htmlto show only html files.
-d→ show dirs only.
-r→ reverse order.
-t→ sort output my 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 dir, “*” for executable, etc.
-p→ show file perm and type and.
-h→ print file size in human readable format.
man tree for detail.
Another useful command is
du. See: Linux: Show Directory Size: du.