根据修改日期复制文件和SUBDIRECTORIES?

时间:2017-05-02 06:06:17

标签: date terminal find copy

这可能是一个重复的问题,但我找不到解决方案,我想将最近3个月的文件和子目录从一个磁盘复制到另一个但我只能通过使用以下命令找到列出文件。我真的不知道如何使用-mtime复制文件。我是linux的新手请帮助我。

 find . -mtime -90 -exec cp {} targetdir \;

但是如何使用子目录和文件复制目录呢? (但不要使用命令rsync,我不要使用此实例)问候S。

1 个答案:

答案 0 :(得分:0)

复制需要指定的递归选项来处理子目录

$ find testroot  # shows some dirs and files
testroot
testroot/sub1
testroot/sub1/subtestfile
testroot/sub2
testroot/testf

$ find target  # empty at this stage
target

$ find ./testroot/ -exec cp -R {} target/ \;

$ find target
target
target/sub1
target/sub1/subtestfile
target/sub2
target/subtestfile
target/testf
相关问题