首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在带有目录列表的文本文件上使用bash tree命令

如何在带有目录列表的文本文件上使用bash tree命令
EN

Stack Overflow用户
提问于 2021-04-06 17:28:31
回答 1查看 33关注 0票数 1

我有一个文本文件,其中包含一些文件夹的目录列表,例如

代码语言:javascript
复制
./boost/1.75.0_2/.brew/boost.rb
./boost/1.75.0_2/include/boost/accumulators/accumulators.hpp
./boost/1.75.0_2/include/boost/accumulators/accumulators_fwd.hpp
./boost/1.75.0_2/include/boost/accumulators/statistics.hpp
./boost/1.75.0_2/include/boost/container/node_allocator.hpp
./boost/1.75.0_2/include/boost/container/node_handle.hpp
./boost/1.75.0_2/include/boost/container/options.hpp

我想使用tree命令来获得以下目录结构的输出:

代码语言:javascript
复制
└── 1.75.0_2
    ├── INSTALL_RECEIPT.json
    ├── README.md
    ├── include
    │   └── boost
    │       ├── accumulators
    │       │   ├── accumulators.hpp
    │       │   ├── accumulators_fwd.hpp
    │       │   ├── framework
    │       │   │   ├── accumulator_base.hpp
    │       │   │   ├── accumulator_concept.hpp
    │       │   │   ├── accumulator_set.hpp
    │       │   │   ├── accumulators
    │       │   │   ├── depends_on.hpp
    │       │   │   ├── external.hpp
    │       │   │   ├── extractor.hpp
    │       │   │   ├── features.hpp
    │       │   │   └── parameters
    │       │   ├── numeric
    │       │   │   ├── detail
    │       │   │   ├── functional
    │       │   │   ├── functional.hpp

我不能访问文件系统,我只有目录列表的文本文件。是否可以对该文件使用tree

EN

回答 1

Stack Overflow用户

发布于 2021-04-06 18:08:13

简单来说,您可以重新创建实际的文件结构(可以在任何地方完成;在/tmp中,在VM中,甚至在远程计算机上),然后运行tree

代码语言:javascript
复制
mkdir tmptree
cd tmptree
sed 's/./\\&/g' yourFile | xargs mkdir -p
tree
cd ..
rm -r tmptree
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66966054

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档