一,tree命令的用途
tree命令以樹狀圖列出文件目錄結構
說明:劉宏締的架構森林是一個專注架構的博客,地址:https://www.cnblogs.com/architectforest
對應的源碼可以訪問這里獲取: https://github.com/liuhongdi/
說明:作者:劉宏締 郵箱: 371125307@qq.com
二,tree命令所屬的包
[liuhongdi@centos8 script]$ whereis tree tree: /usr/bin/tree /usr/share/man/man1/tree.1.gz [liuhongdi@centos8 script]$ rpm -qf /usr/bin/tree tree-1.7.0-15.el8.x86_64
如果提示找不到tree命令,可以用dnf做安裝
[root@centos8 ~]# dnf install tree
三,查看tree命令的版本和幫助
1,查看版本:
[root@centos8 ~]# tree --version tree v1.7.0 (c) 1996 - 2014 by Steve Baker, Thomas Moore, Francesc Rocher, Florian Sesser, Kyosuke Tokoro
2,查看幫助
[root@centos8 ~]# tree --help
3,查看手冊
[root@centos8 ~]# man tree
四,tree命令常見的用法舉例:
1,列出目錄下的文件(不顯示隱藏文件)
#不用加任何參數
[root@centos8 ~]# tree /home/liuhongdi/
2,列出目錄下的文件,包括隱藏文件
#-a:顯示所有文件:包括隱藏文件在內
[root@centos8 ~]# tree -a /home/liuhongdi/
3, 指定目錄的顯示深度
#-L level Descend only level directories deep
#-L 2:只顯示兩層目錄
[root@centos8 ~]# tree -L 2 /home/liuhongdi/
4,顯示文件的完整路徑
#-f:Print the full path prefix for each file
[root@centos8 ~]# tree -f /home/liuhongdi/
5,顯示文件的大小:
#-s:打印文件的大小
#-h:以人性化方式打印大小
[root@centos8 ~]# tree -sh /home/liuhongdi/
6,只顯示目錄:
#-d: List directories only
[root@centos8 ~]# tree -d /home/liuhongdi/
7,指定以json格式輸出:
#-J:Prints out an JSON representation of the tree
[root@centos8 ~]# tree -J /home/liuhongdi/
8,打印出文件屬性:
#-F :在執行文件,目錄,Socket,符號連接,管道名稱名稱,各自加上"*","/","=","@","|"號
[root@centos8 ~]# tree -F /home/liuhongdi/
五,查看centos版本
[root@centos8 ~]# cat /etc/redhat-release CentOS Linux release 8.1.1911 (Core)