当前位置:网站首页>文件夹目录结构自动生成
文件夹目录结构自动生成
2022-06-12 11:36:00 【achi010】
前言
写文章的时候,经常会需要说明文件家的目录结构。如果手动打印输出,排版繁琐、容易出错,自动化怎么搞?
一、结果示例
C:.
└─node_modules
├─npm
│ ├─.github
│ │ ├─ISSUE_TEMPLATE
│ │ └─workflows
│ ├─bin
│ │ └─node-gyp-bin
│ ├─changelogs
│ ├─docs
│ │ ├─content
│ │ │ ├─cli-commands
│ │ │ ├─configuring-npm
│ │ │ └─using-npm
│ │ └─src
│ │ ├─components
│ │ │ └─home
│ │ ├─images
│ │ ├─pages
│ │ └─templates
│ ├─lib
│ │ ├─auth
│ │ ├─config
│ │ ├─doctor
│ │ ├─install
│ │ │ └─action
│ │ ├─search
│ │ └─utils
二、Windows 11
操作系统: Windows 11 & 10
Windows 系统 tree 命令,可通过该命令实现。
示例
Windows 11 示例如下
简单使用
C:\Programming\nodejs>tree
卷 Windows-SSD 的文件夹 PATH 列表
卷序列号为 4288-DA87
C:.
└─node_modules
├─npm
│ ├─.github
│ │ ├─ISSUE_TEMPLATE
│ │ └─workflows
│ ├─bin
│ │ └─node-gyp-bin
│ ├─changelogs
│ ├─docs
帮助
# 帮助
C:\Programming\nodejs>tree /?
以图形显示驱动器或路径的文件夹结构。
TREE [drive:][path] [/F] [/A]
/F 显示每个文件夹中文件的名称。
/A 使用 ASCII 字符,而不使用扩展字符。
结果输出到文件
C:\Programming\nodejs>tree > demo.md
三、node.js 的 tree
操作系统: CentOS Linux release 7.9.2009 (Core)
node.js: v16.15.0
1.node.js
# 下载
wget https://cdn.npmmirror.com/binaries/node/v16.15.0/node-v16.15.0-linux
-x64.tar.xz
# 解压
tar -xvf node-v16.15.0-linux-x64.tar.xz
# 配置(不配置也可,能找到命令目录即可)
ln -s /node-v16.15.0-linux-x64/bin/npm /usr/local/bin
ln -s /node-v16.15.0-linux-x64/bin/node /usr/local/bin
# 验证配置是否成功
node -v
nopm -v
2.tree
安装 tree
# 全局安装 tree
npm i tree-node-cli -g
# 安装完之后,node 所在目录会增加 tree
/node-v16.15.0-linux-x64/bin/tree
# 配置
ln -s /node-v16.15.0-linux-x64/bin/tree /usr/local/bin
# 验证配置
tree -V
文件夹目录结构自动生成,并输出到文件
# 示例
tree -L 2 > README.md
# 结果
node-v16.15.0-linux-x64
├── CHANGELOG.md
├── LICENSE
├── README.md
├── bin
│ ├── README.md
│ ├── corepack
│ ├── node
│ ├── npm
│ ├── npx
│ ├── tree
│ └── treee
├── include
│ └── node
├── lib
│ └── node_modules
└── share
├── doc
├── man
└── systemtap
# 帮助
tree -h
PS : 对比之下,感觉 Windows 的 tree 就是个渣渣。Windows 也可以使用 node 的这个方法,配置方法是一样的。
Windows 安装配置 node 可以参考
总结
其实方法比较简单。关键是要找对方法~~!!!
边栏推荐
猜你喜欢

Socket implements TCP communication flow

人類想要擁有金錢、權力、美麗、永生、幸福……但海龜只想做一只海龜

Relatively rare exception records in UI automation test

视频分类的类间和类内关系——正则化

Doris records service interface calls

人类想要拥有金钱、权力、美丽、永生、幸福……但海龟只想做一只海龟

InfoQ geek media's 15th anniversary solicitation |position:fixed virtual button cannot take effect after being triggered. Problem analysis and Solution Exploration

Clickhouse column basic data type description

6.6 separate convolution

Doris记录服务接口调用情况
随机推荐
【数据库】sqlite版本升级、降级
Problems in cross validation code of 10% discount
[the 11th national competition of Blue Bridge Cup single chip microcomputer]
scanf返回值被忽略的原因及其解决方法
go基于阿里云实现发送短信
Process creation and recycling
LVS health state detection based on application layer
正则表达式 | 浅解
Logrotate log rotation method create and copyruncate principles
网络的拓扑结构
C# 36. DataGridView行号
FPGA Development - Hello_ World routine
Lambda表达式 | 浅解
NLP data set download address for naturallanguageprocessing
K58. Chapter 1 installing kubernetes V1.23 based on kubeadm -- cluster deployment
B+ 树的简单认识
人類想要擁有金錢、權力、美麗、永生、幸福……但海龜只想做一只海龜
套接字编程TCP篇
Doris记录服务接口调用情况
Go sends SMS based on Tencent cloud