欢迎光临!请记住我的域名:http://wish123.cnblogs.com
代码改变世界

linux find 模拟tree命令

2014-09-18 09:47  wish123  阅读(819)  评论(0编辑  收藏  举报

有些服务器下默认是没有 tree命令的,不过我们可以使用find命令模拟出tree命令的效果,如显示当前目录的 tree 的命令:

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

 

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

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