繁体   English   中英

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

[英]How to use bash tree command on a text file with directory listing

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

./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命令获取以下output的目录结构:

└── 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

作为一个快速破解,您可以重新创建实际的文件结构(可以在任何地方完成;在/tmp中,在 VM 中,甚至在远程机器上)然后运行tree

mkdir tmptree
cd tmptree
sed 's/./\\&/g' yourFile | xargs mkdir -p
tree
cd ..
rm -r tmptree

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM