安装tree命令 - linux和mac下

centOS下的安装:

yum -y install tree

 

Ubuntu下安装:

sudo apt-get install tree

 

命令的使用:

tree或者tree -a    //显示当前目录下的所有文件和子文件
tree -f    //在每个文件或目录之前,显示完整的相对路径名称

 

 

 

 

 

 

mac下:

第一种:1、直接使用find命令模拟出tree命令的效果,如显示当前目录的 tree 的命令:

find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'

第二种:写一个别名来快速执行该命令,运行如下命令,将上面这个命令写到~/.bash_profile里,以后直接运行tree命令就更方便了

alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'"

第三种:使用 homebrew 安装 tree 命令行:

brew install tree

 

————非常遗憾,第三种我没有尝试成功。

 

posted @ 2017-12-18 12:14  小寒1206  阅读(1914)  评论(0编辑  收藏  举报