简体   繁体   English

从TREE命令输出创建目录和文件

[英]Creating directories and files from TREE command output

I've used a tree command to list recursively about a hundred folders with some 150 files in them. 我已经使用树命令递归列出大约一百个文件夹,其中包含大约150个文件。 This tree output is saved in a file. 此树输出保存在文件中。

How can I parse this file via bash and recreate these files and folders on a different computer? 如何通过bash解析此文件并在另一台计算机上重新创建这些文件和文件夹?

Note that I don't need to copy these files. 请注意,我不需要复制这些文件。 All I need is just the same naming convention on another computer where some custom work will be done. 我需要的只是在另一台计算机上的相同命名约定,其中将完成一些自定义工作。

find will do what you want, something like 找到会做你想要的东西,比如

find /my/pathto/blah -type d | sed -e "s/^/mkdir -p /g" > commands
find /my/pathto/blah -type f | sed -e "s/^/touch /g" >> commands

The first find will create the instructions to make the directories. 第一个find将创建制作目录的指令。 The second find will create the instructions to create empty files. 第二个find将创建创建空文件的指令。

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

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