Linux find 模拟 tree 命令

2024-05-11 0 1
手机查看

有些服务器下默认是没有 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'"

效果:
Pastedimage20240221051749.png

What do you think?
  • 点赞
    0
    点赞
  • 踩一下
    0
    踩一下
  • 酷毙了
    0
    酷毙了
  • 不屑
    0
    不屑
  • 尴尬
    0
    尴尬
  • 无聊
    0
    无聊
Comments
  • Latest
  • Oldest
  • Hottest
Powered by Waline v3.5.6