方式一

Mac 系统下默认是不带这条命令的,执行下面这条命令也可以打印出树状结构。

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

不想每次都输入这么长一条命令怎么办?用 alias 给这条命令指定一条别名,方法步骤如下:

Step 1 :创建 .bash_profile 文件

cd ~
touch .bash_profile
open .bash_profile

Step 2:把下面的命令保存在这个文件中

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

Step 3:执行下面命令

source .bash_profile

 

方式二

安装 tree 命令

brew install tree

使用方法:

tree                         #打印所有目录层级
tree -L 2                    #遍历2层
tree > README.md             #输出结果到 Markdown 文档 

大功告成!找个目录试试直接 tree 吧!

Mac 下如何使用 Tree 命令

 

相关文章:

  • 2021-10-06
  • 2022-12-23
  • 2022-12-23
  • 2021-11-28
  • 2022-12-23
  • 2022-12-23
  • 2021-09-04
  • 2021-04-18
猜你喜欢
  • 2022-02-05
  • 2021-09-20
  • 2021-06-24
  • 2022-12-23
  • 2021-12-03
相关资源
相似解决方案