将目录结构的一部分复制到新位置 [英] Copying part of a directory structure to a new location

查看:53
本文介绍了将目录结构的一部分复制到新位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个相对较大的目录结构,该结构在组织上非常一致,我需要将其中的一部分复制到新位置.

I have a relatively large directory structure that is very consistent in its organization and I need to copy part of it to a new location.

这就是我所拥有的:

./dev
    /man
        <.txt files>
    /other dir
    /another dir  
./mod
    /man
        <.txt files>
    /other dir
    /another dir
 ./blah
    /other dir
    /another dir

我感兴趣的是man目录中的.txt文件.有些目录带有/man/,有些则没有,例如上面的./blah.

What I'm interested in are the .txt files in the man directory. Some of the directories have /man/ and some don't, like ./blah above.

我需要做的是在新位置使用/man/复制目录结构:

What I need to do is to reproduce the directory structure with the /man/ in a new location:

/opt/dev
    /man
        <.txt files>
/opt/mod
    /man
        <.txt files>

我尝试了find,rsync,cp等多种变体,但是没有找到有效的方法.

I've tried a number of different variations of find, rsync, cp, etc. and haven't found something that works.

推荐答案

这对我有用: cp --parents ./*/man/*.txt/opt

这篇关于将目录结构的一部分复制到新位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆