For a detailed analysis of dtree-Linux general technology-Linux programming and kernel information, see the following for details. : 0) 1
To view the original article, please visit my blog: http://blog.sina.com.cn/baoxiaopan
These days, after intense discussions with Acheng students, I finally had a general and clear understanding of the following scripts. although the two lines are simple and simple, they still involve a wide range of things, there must be more than a desire to learn and an enthusiasm for continuous learning. I will explain some of my understandings as follows, and some points may not be clear, however, I still think that I have already expressed what I want to express. if you find any errors or supplements, please email me. thank you very much. Of course, if there is not clear, also feel free to email or QQ contact me: [url = xiaopan3322@gmail.com] xiaopan3322@gmail.com [/url], 157526632.
Description:
Dtree is a utility that will display a directory hierarchy or tree.
While Linux comes with hundreds of utilities, something you got used to on another system always seems to be missing. One program in this category is something that will display a directory hierarchy or tree.
While some file managers that run under X-Windows will do this sort of task, it is sometimes very handy to have a command-line version. while not Linux-specific, the dtree utility is such a program.
I will first explain how to use dtree, then explain how it works. if you invoke it by just entering its name it will display the directory hierarchy starting at the current directory. if you invoke it with an argument, that argument is used as the starting directory. for example, if you enter dtree/home/fyl/Cool, a tree of directories under/home/fyl/Cool will be displayed.
Dtree is written in the finest old-time Unix tradition using common utilities with a short shell script to glue them together. Here is the program:
Script code:
CODE :#! /Bin/bash
# Print a hierarchy tree starting
# Specified directory (. default)
(Cd $ {1-.}; pwd)
Find ${1 -.} -type d-print | sort-f | sed-e "s, ^ ${1 -.},, "-e"/^ $/d "-e's, [^/] */\ ([^/] * \) $, '----- \ 1, '-e "s, [^/] */, |, g" |