linux - 将目录结构的一部分复制到新位置

标签 linux command-line

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

这是我所拥有的:

./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。

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

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

我尝试了 find、rsync、cp 等多种不同的变体,但没有找到有效的方法。

最佳答案

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

关于linux - 将目录结构的一部分复制到新位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25437345/

相关文章:

ios - 将名称中包含某些字符的文件移动到 IOS/linnux 终端中的不同目录

java - 带有非常量 case 的 switch 语句

sql - oracle 行计数到 shell 脚本变量

bash - Visual Studio Code 未使用 'code' 命令打开

linux - NGINX dns 不适用于 VPS

linux - 使用 shell 脚本从主机名或 FQDN 获取 IP

c - 在 C 中实现命令行解释器,特殊情况

github - 如何从 Azure DevOps Pipeline Dynamics 365 CE 添加/更新 git 存储库中的文件

linux - 如何判断 Unix 管道中的下游进程是否已崩溃

linux - chmod : cannot access ‘\r’ : No such file or directory