开发者

Creating directories and files from TREE command output

开发者 https://www.devze.com 2023-03-31 23:58 出处:网络
I\'ve used a tree command to 开发者_Python百科list recursively about a hundred folders with some 150 files in them. This tree output is saved in a file.

I've used a tree command to 开发者_Python百科list recursively about a hundred folders with some 150 files in them. 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?

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. The second find will create the instructions to create empty files.

0

精彩评论

暂无评论...
验证码 换一张
取 消