码迷,mamicode.com
首页 > 系统相关 > 详细

Mac 下如何使用 Tree 命令

时间:2016-12-03 20:49:41      阅读:277      评论:0      收藏:0      [点我收藏+]

标签:sed -e   nbsp   png   树状   安装   file   print   ges   指定   

方式一

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 命令

标签:sed -e   nbsp   png   树状   安装   file   print   ges   指定   

原文地址:http://www.cnblogs.com/zhaowmm/p/6129342.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!