Linux find 模拟 tree 命令,牛
有些服务器下默认是没有 tree命令的,不过我们可以使用find命令模拟出tree命令的效果,如显示当前目录的 tree 的命令:$ find . -print | sed -e ``'s;[^/]*/;|____;g;s;____|; |;g'
当然你也可以写一个别名来快速执行该命令,运行如下命令,将上面这个命令写到~/.bash_profile里,以后直接运行tree命令就更方便了:alias tree=``"find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'"
效果:
本帖已被设为精华帖!
本帖由系统于 4年前 自动加精
能写出这样的 sed 表达式也是很厉害了。
牛:+1:
太厉害了!!!