相信不少使用過Linux的用戶都用過tree
命令,它能夠像windows的文件管理器同樣清楚明瞭的顯示目錄結構。mac 下使用 brew包管理工具安裝 treeshell
前提:安裝了homebrewwindows
brew install tree
正常的顯示開始安裝(這纔是開始下載)工具
Downloading https://homebrew.bintray.com/bottles/tree-1.8.0.mojave.bottle.tar.gz
若是報錯spa
Error: The following directories are not writable by your user: /usr/local/sbin You should change the ownership of these directories to your user. sudo chown -R $(whoami) /usr/local/sbin And make sure that your user has write permission. chmod u+w /usr/local/sbin
要先按照上面的指令執行code
chmod u+w /usr/local/sbin sudo chown -R $(whoami) /usr/local/sbin # 這裏會讓輸入登陸密碼,輸入便可
安裝成功後,直接在終端使用, 使用 --help 查看幫助信息blog
tree --help
在目錄遍歷時使用 -L 參數指定遍歷層級
tree -L 1 #-L 1 指只顯示一級目錄
把一個目錄的結構樹導出到文件 Readme.mdhomebrew
tree -L 2 >README.md
若是要查看的目錄包含中文,用:ip
tree -N