简体   繁体   English

复制文件夹结构和仅文件名

[英]Copy folder structure and only files name

I want to create a clone of the structure of one big folder (500Gb). 我想创建一个大文件夹(500Gb)结构的克隆。 I can do this easily with the below command : 我可以使用以下命令轻松完成此操作:

cd /path/to/directories && find . cd / path / to / directories &&查找。 -type d -exec mkdir -p -- /path/to/backup/{} \\; -类型d -exec mkdir -p-/ path / to / backup / {} \\;

Now I also want to clone files (I mean copy each file but empty files) 现在我也想克隆文件(我的意思是复制每个文件,但复制空文件)

For example let's suggest /path/to/directories/file.txt takes 1Gb space. 例如,我们建议/path/to/directories/file.txt占用1Gb空间。 I want /path/to/backup/file.txt to be empty ( 1Kb ) 我希望/path/to/backup/file.txt为1Kb

Maybe I can use this command 也许我可以使用此命令

> filename

Any idea ? 任何想法 ?

Try this: 尝试这个:

cd /path/to/dirs ; cd / path / to / dirs; find | 找到 while read f ; 同时读f; do [ ! 做[! -d "$f" ] && touch "/path/to/backup/$f" || -d“ $ f”] &&触摸“ / path / to / backup / $ f” || mkdir -p "/path/to/backup/$f" ; mkdir -p“ /路径/到/备份/ $ f”; done DONE

Regards 问候

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

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