Mac 显示目录结构

目的:列出目录结构
本地使用


   brew install tree

安装了tree,

brew list    //显示有tree
cscope    jpeg    libpng    macvim    tree    webp    xz

但是测试的时候

➜  ~ tree -d usr/
sed: illegal option -- d
usage: sed script [-Ealn] [-i extension] [file ...]
       sed [-Ealn] [-i extension] [-e script] ... [-f script_file] ... [file ...]
   

提示有错误,目前只能使用tree命令?目前版本是1.7.0,会不会是版本的问题?还是哪里操作出错。

谢谢!

阅读 4.5k
3 个回答

which tree 看一下是不是被替换成 sed 了,1.7.0 在我这里没问题

有个更简单的方法:
写一句alias到bash profile

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

brew install tree
tree -L 2
2 is the depth of the tree.

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进