最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】Linux列出文件夹和文件的目录结构树即用tree列出目录的树状结构

Linux crifan 3551浏览 0评论

折腾:

【已解决】python中的相对路径导入库失败No module named

期间,需要去把当前项目的目录结构的,包括文件和文件夹:

以树形,带缩进的方式去显示

试了试ls的-r,没有类似效果:

<code>(debug_nlp-wDGPvi3o) [root@xx-general-01 nlp]# ll -r
total 4
</code>

(后来

Linux下的tree命令 –Linux下目录树查看 – CSDN博客

知道了:

<code>ls -R
</code>

但是还是不够好。)

搜:

linux ls 目录树缩进

Linux用树形结构显示目录结构 – CSDN博客

linux tree命令–显示目录的树形结构 – CSDN博客

Linux下的tree命令 –Linux下目录树查看 – CSDN博客

期间也多知道了个ls的-F参数的效果:

&lt;code&gt;(debug_nlp-wDGPvi3o) [root@xx-general-01 nlp]# ls -F
xxx/
(debug_nlp-wDGPvi3o) [root@xx-general-01 nlp]# cd xxx/
(debug_nlp-wDGPvi3o) [root@xx-general-01 xxx]# ll
total 32
drwxr-xr-x 2 root root 4096 Jun&nbsp;&nbsp;6 17:18 conf
-rw-r--r-- 1 root root&nbsp;&nbsp;&nbsp;&nbsp;0 Jun&nbsp;&nbsp;7 10:21 __init__.py
drwxr-xr-x 3 root root 4096 Jun&nbsp;&nbsp;6 17:18 nlp
-rw-r--r-- 1 root root&nbsp;&nbsp;201 May 29 15:19 Pipfile
-rw-r--r-- 1 root root 5745 May 29 15:20 Pipfile.lock
drwxr-xr-x 5 root root 4096 Jun&nbsp;&nbsp;7 10:22 processData
-rw-r--r-- 1 root root 2462 Jun&nbsp;&nbsp;6 17:43 README.md
drwxr-xr-x 3 root root 4096 Jun&nbsp;&nbsp;7 10:55 util
(debug_nlp-wDGPvi3o) [root@xx-general-01 xx]# ls -F
conf/&nbsp;&nbsp;__init__.py&nbsp;&nbsp;nlp/&nbsp;&nbsp;Pipfile&nbsp;&nbsp;Pipfile.lock&nbsp;&nbsp;processData/&nbsp;&nbsp;README.md&nbsp;&nbsp;util/
(debug_nlp-wDGPvi3o) [root@xx-general-01 xxx]# ls -lF
total 32
drwxr-xr-x 2 root root 4096 Jun&nbsp;&nbsp;6 17:18 conf/
-rw-r--r-- 1 root root&nbsp;&nbsp;&nbsp;&nbsp;0 Jun&nbsp;&nbsp;7 10:21 __init__.py
drwxr-xr-x 3 root root 4096 Jun&nbsp;&nbsp;6 17:18 nlp/
-rw-r--r-- 1 root root&nbsp;&nbsp;201 May 29 15:19 Pipfile
-rw-r--r-- 1 root root 5745 May 29 15:20 Pipfile.lock
drwxr-xr-x 5 root root 4096 Jun&nbsp;&nbsp;7 10:22 processData/
-rw-r--r-- 1 root root 2462 Jun&nbsp;&nbsp;6 17:43 README.md
drwxr-xr-x 3 root root 4096 Jun&nbsp;&nbsp;7 10:55 util/
&lt;/code&gt;

【总结】

然后试试tree的效果

&lt;code&gt;(debug_nlp-wDGPvi3o) [root@xx-general-01 xx]# tree
.
├── conf
│&nbsp;&nbsp; └── main.conf
├── __init__.py
├── nlp
│&nbsp;&nbsp; └── dialog
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── AccessData.py
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── Analyzer.py
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── config
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; └── config.ini
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── data
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── __init__.py
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; └── reply.txt
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── DialogueManager.py
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── files
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── control.txt
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; └── test.txt
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── GenerateResponse.py
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── __init__.py
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── intent.py
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── SearchData.py
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;└── tmp.py
├── Pipfile
├── Pipfile.lock
├── processData
│&nbsp;&nbsp; ├── __init__.py
│&nbsp;&nbsp; ├── mysqlQa
│&nbsp;&nbsp; │&nbsp;&nbsp; ├── __init__.py
│&nbsp;&nbsp; │&nbsp;&nbsp; ├── MongodbToMysqlQa.py
│&nbsp;&nbsp; │&nbsp;&nbsp; ├── README.md
│&nbsp;&nbsp; │&nbsp;&nbsp; └── vocabulary.txt
│&nbsp;&nbsp; ├── mysqlThesaurus
│&nbsp;&nbsp; │&nbsp;&nbsp; ├── vocabularyToMysql.py
│&nbsp;&nbsp; │&nbsp;&nbsp; └── \350\257\215\346\261\207\350\241\250\ 180531.xlsx
│&nbsp;&nbsp; └── other
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;└── to_delete
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── resource.2018.1.29.xlsx
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── resource.xlsx
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;└── xlstomysql.py
├── README.md
└── util
&nbsp;&nbsp;&nbsp;&nbsp;├── configs.py
&nbsp;&nbsp;&nbsp;&nbsp;├── crifanLib
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanBeautifulsoup.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanCookie.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanDatetime.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanEmail.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanFile.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanGeography.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanHtml.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanHttp.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanList.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanLogging.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanMath.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanMysql.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanOpenpyxl.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanString.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanSystem.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanTemplate.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanUrl.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; └── __init__.py
&nbsp;&nbsp;&nbsp;&nbsp;├── dbcon.py
&nbsp;&nbsp;&nbsp;&nbsp;├── __init__.py
&nbsp;&nbsp;&nbsp;&nbsp;└── paths.py

13 directories, 50 files
&lt;/code&gt;

加上-F -》文件夹后面加上斜杠:

&lt;code&gt;(debug_nlp-wDGPvi3o) [root@xx-general-01 xx]# tree -F
.
├── conf/
│&nbsp;&nbsp; └── main.conf
├── __init__.py
├── nlp/
│&nbsp;&nbsp; └── dialog/
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── AccessData.py
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── Analyzer.py
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── config/
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; └── config.ini
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── data/
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── __init__.py
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; └── reply.txt
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── DialogueManager.py
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── files/
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── control.txt
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; └── test.txt
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── GenerateResponse.py
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── __init__.py
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── intent.py
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── SearchData.py
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;└── tmp.py
├── Pipfile
├── Pipfile.lock
├── processData/
│&nbsp;&nbsp; ├── __init__.py
│&nbsp;&nbsp; ├── mysqlQa/
│&nbsp;&nbsp; │&nbsp;&nbsp; ├── __init__.py
│&nbsp;&nbsp; │&nbsp;&nbsp; ├── MongodbToMysqlQa.py
│&nbsp;&nbsp; │&nbsp;&nbsp; ├── README.md
│&nbsp;&nbsp; │&nbsp;&nbsp; └── vocabulary.txt
│&nbsp;&nbsp; ├── mysqlThesaurus/
│&nbsp;&nbsp; │&nbsp;&nbsp; ├── vocabularyToMysql.py
│&nbsp;&nbsp; │&nbsp;&nbsp; └── \350\xxx50\ 180531.xlsx
│&nbsp;&nbsp; └── other/
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;└── to_delete/
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── resource.2018.1.29.xlsx
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── resource.xlsx
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;└── xlstomysql.py
├── README.md
└── util/
&nbsp;&nbsp;&nbsp;&nbsp;├── configs.py
&nbsp;&nbsp;&nbsp;&nbsp;├── crifanLib/
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanBeautifulsoup.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanCookie.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanDatetime.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanEmail.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanFile.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanGeography.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanHtml.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanHttp.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanList.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanLogging.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanMath.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanMysql.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanOpenpyxl.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanString.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanSystem.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanTemplate.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanUrl.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; └── __init__.py
&nbsp;&nbsp;&nbsp;&nbsp;├── dbcon.py
&nbsp;&nbsp;&nbsp;&nbsp;├── __init__.py
&nbsp;&nbsp;&nbsp;&nbsp;└── paths.py

13 directories, 50 files
&lt;/code&gt;

带上-C,彩色的输出:

完整的-CF的效果:

&lt;code&gt;(debug_nlp-wDGPvi3o) [root@xx-general-01 xx]# tree -CF
.
├── conf/
│&nbsp;&nbsp; └── main.conf
├── __init__.py
├── nlp/
│&nbsp;&nbsp; └── dialog/
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── AccessData.py
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── Analyzer.py
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── config/
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; └── config.ini
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── data/
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── __init__.py
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; └── reply.txt
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── DialogueManager.py
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── files/
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── control.txt
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; └── test.txt
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── GenerateResponse.py
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── __init__.py
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── intent.py
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── SearchData.py
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;└── tmp.py
├── Pipfile
├── Pipfile.lock
├── processData/
│&nbsp;&nbsp; ├── __init__.py
│&nbsp;&nbsp; ├── mysqlQa/
│&nbsp;&nbsp; │&nbsp;&nbsp; ├── __init__.py
│&nbsp;&nbsp; │&nbsp;&nbsp; ├── MongodbToMysqlQa.py
│&nbsp;&nbsp; │&nbsp;&nbsp; ├── README.md
│&nbsp;&nbsp; │&nbsp;&nbsp; └── vocabulary.txt
│&nbsp;&nbsp; ├── mysqlThesaurus/
│&nbsp;&nbsp; │&nbsp;&nbsp; ├── vocabularyToMysql.py
│&nbsp;&nbsp; │&nbsp;&nbsp; └── \350\257\215\346\261\207\350\241\250\ 180531.xlsx
│&nbsp;&nbsp; └── other/
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;└── to_delete/
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── resource.2018.1.29.xlsx
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├── resource.xlsx
│&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;└── xlstomysql.py
├── README.md
└── util/
&nbsp;&nbsp;&nbsp;&nbsp;├── configs.py
&nbsp;&nbsp;&nbsp;&nbsp;├── crifanLib/
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanBeautifulsoup.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanCookie.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanDatetime.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanEmail.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanFile.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanGeography.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanHtml.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanHttp.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanList.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanLogging.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanMath.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanMysql.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanOpenpyxl.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanString.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanSystem.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanTemplate.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; ├── crifanUrl.py
&nbsp;&nbsp;&nbsp;&nbsp;│&nbsp;&nbsp; └── __init__.py
&nbsp;&nbsp;&nbsp;&nbsp;├── dbcon.py
&nbsp;&nbsp;&nbsp;&nbsp;├── __init__.py
&nbsp;&nbsp;&nbsp;&nbsp;└── paths.py

13 directories, 50 files
&lt;/code&gt;

【后记】

后来想要在Mac中也使用tree,但是发现Mac中此处没有tree这个工具。

所以也要去安装和使用。

mac tree

mac 下的 tree 命令 终端展示你的目录树结构 一介布衣

&lt;code&gt;➜&nbsp;&nbsp;gitbook_template git:(master) brew install tree
==&amp;gt; Downloading https://homebrew.bintray.com/bottles-portable-ruby/portable-ruby-2.3.3_2.leopard_64.bottle.tar.gz
######################################################################## 100.0%
==&amp;gt; Pouring portable-ruby-2.3.3_2.leopard_64.bottle.tar.gz
Updating Homebrew...
==&amp;gt; Downloading https://homebrew.bintray.com/bottles/tree-1.7.0.high_sierra.bottle.1.tar.gz
######################################################################## 100.0%
==&amp;gt; Pouring tree-1.7.0.high_sierra.bottle.1.tar.gz
🍺&nbsp;&nbsp;/usr/local/Cellar/tree/1.7.0: 8 files, 114.3KB
➜&nbsp;&nbsp;gitbook_template git:(master) ✗ which tree
/usr/local/bin/tree
➜&nbsp;&nbsp;gitbook_template git:(master) ✗ tree --version
tree v1.7.0 (c) 1996 - 2014 by Steve Baker, Thomas Moore, Francesc Rocher, Florian Sesser, Kyosuke Tokoro
&lt;/code&gt;

看看效果:

&lt;code&gt;➜&nbsp;&nbsp;gitbook_template git:(master) ✗ tree -CF
.
├── GitbookCommon.mk
├── README.md
├── book_common.json
├── generateBookJson.py
├── gitbook_demo/
│&nbsp;&nbsp; ├── Makefile
│&nbsp;&nbsp; └── book_current.json
└── sshpass_password.txt

1 directory, 7 files
&lt;/code&gt;

换个目录,去试试

mac电脑终端怎么显示项目树:tree命令的使用 – 个人前端分享 – SegmentFault 思否

mac 下的 tree 命令 终端展示你的目录树结构 一介布衣

MAC终端中安装命令行工具TREE | Aitter’s Blog

“  -L level      Descend only level directories deep.”

提到的-L 层级个数

对于目录:

试试:-L 2

&lt;code&gt;➜&nbsp;&nbsp;youdao_note_summary git:(master) ✗ tree -CF -L 2
.
├── Makefile
├── README.md
├── book.json
├── book_current.json
├── debug/
│&nbsp;&nbsp; ├── appendix/
│&nbsp;&nbsp; ├── assets/
│&nbsp;&nbsp; ├── gitbook/
│&nbsp;&nbsp; ├── index.html
│&nbsp;&nbsp; ├── search_plus_index.json
│&nbsp;&nbsp; ├── sitemap.xml
│&nbsp;&nbsp; ├── youdao_background/
│&nbsp;&nbsp; ├── youdao_common/
│&nbsp;&nbsp; ├── youdao_cooperation/
│&nbsp;&nbsp; └── youdao_note/
├── node_modules/
│&nbsp;&nbsp; ├── boolbase/
│&nbsp;&nbsp; ├── cheerio/
│&nbsp;&nbsp; ├── clipboard/
│&nbsp;&nbsp; ├── core-util-is/
│&nbsp;&nbsp; ├── css-select/
│&nbsp;&nbsp; ├── css-what/
│&nbsp;&nbsp; ├── delegate/
│&nbsp;&nbsp; ├── dom-serializer/
│&nbsp;&nbsp; ├── domelementtype/
│&nbsp;&nbsp; ├── domhandler/
│&nbsp;&nbsp; ├── domutils/
│&nbsp;&nbsp; ├── entities/
│&nbsp;&nbsp; ├── gitbook-plugin-alerts/
│&nbsp;&nbsp; ├── gitbook-plugin-bootstrap-callout/
│&nbsp;&nbsp; ├── gitbook-plugin-callouts/
│&nbsp;&nbsp; ├── gitbook-plugin-copy-code-button/
│&nbsp;&nbsp; ├── gitbook-plugin-disqus/
│&nbsp;&nbsp; ├── gitbook-plugin-donate/
│&nbsp;&nbsp; ├── gitbook-plugin-expandable-chapters-small/
│&nbsp;&nbsp; ├── gitbook-plugin-ga/
│&nbsp;&nbsp; ├── gitbook-plugin-github-buttons/
│&nbsp;&nbsp; ├── gitbook-plugin-prism/
│&nbsp;&nbsp; ├── gitbook-plugin-prism-themes/
│&nbsp;&nbsp; ├── gitbook-plugin-search-plus/
│&nbsp;&nbsp; ├── gitbook-plugin-sharing-plus/
│&nbsp;&nbsp; ├── gitbook-plugin-sitemap-general/
│&nbsp;&nbsp; ├── gitbook-plugin-splitter/
│&nbsp;&nbsp; ├── gitbook-plugin-tbfed-pagefooter/
│&nbsp;&nbsp; ├── gitbook-plugin-theme-comscore/
│&nbsp;&nbsp; ├── gitbook-plugin-toolbar-button/
│&nbsp;&nbsp; ├── good-listener/
│&nbsp;&nbsp; ├── html-entities/
│&nbsp;&nbsp; ├── htmlparser2/
│&nbsp;&nbsp; ├── inherits/
│&nbsp;&nbsp; ├── isarray/
│&nbsp;&nbsp; ├── lodash/
│&nbsp;&nbsp; ├── lodash.assignin/
│&nbsp;&nbsp; ├── lodash.bind/
│&nbsp;&nbsp; ├── lodash.defaults/
│&nbsp;&nbsp; ├── lodash.filter/
│&nbsp;&nbsp; ├── lodash.flatten/
│&nbsp;&nbsp; ├── lodash.foreach/
│&nbsp;&nbsp; ├── lodash.map/
│&nbsp;&nbsp; ├── lodash.merge/
│&nbsp;&nbsp; ├── lodash.pick/
│&nbsp;&nbsp; ├── lodash.reduce/
│&nbsp;&nbsp; ├── lodash.reject/
│&nbsp;&nbsp; ├── lodash.some/
│&nbsp;&nbsp; ├── minimist/
│&nbsp;&nbsp; ├── mkdirp/
│&nbsp;&nbsp; ├── moment/
│&nbsp;&nbsp; ├── nth-check/
│&nbsp;&nbsp; ├── prism-themes/
│&nbsp;&nbsp; ├── prismjs/
│&nbsp;&nbsp; ├── process-nextick-args/
│&nbsp;&nbsp; ├── readable-stream/
│&nbsp;&nbsp; ├── safe-buffer/
│&nbsp;&nbsp; ├── select/
│&nbsp;&nbsp; ├── sitemap/
│&nbsp;&nbsp; ├── string_decoder/
│&nbsp;&nbsp; ├── tiny-emitter/
│&nbsp;&nbsp; ├── underscore/
│&nbsp;&nbsp; ├── url-join/
│&nbsp;&nbsp; └── util-deprecate/
├── output/
│&nbsp;&nbsp; └── youdao_note_summary/
└── src/
&nbsp;&nbsp;&nbsp;&nbsp;├── README.md
&nbsp;&nbsp;&nbsp;&nbsp;├── SUMMARY.md
&nbsp;&nbsp;&nbsp;&nbsp;├── appendix/
&nbsp;&nbsp;&nbsp;&nbsp;├── assets/
&nbsp;&nbsp;&nbsp;&nbsp;├── youdao_background/
&nbsp;&nbsp;&nbsp;&nbsp;├── youdao_common/
&nbsp;&nbsp;&nbsp;&nbsp;├── youdao_cooperation/
&nbsp;&nbsp;&nbsp;&nbsp;└── youdao_note/

82 directories, 9 files
➜&nbsp;&nbsp;youdao_note_summary git:(master) ✗
&lt;/code&gt;

效果还是不错的。

转载请注明:在路上 » 【已解决】Linux列出文件夹和文件的目录结构树即用tree列出目录的树状结构

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
84 queries in 0.188 seconds, using 22.13MB memory