[英]How to copy the recent updated multiple files in another directory in Solaris
I want to copy the recently updated multiple file into another directory. 我想将最近更新的多个文件复制到另一个目录。
I am having 1.xml,2.xml,3.xml.... in this directory recently someone updated file or added new file into the directory,So i want to copy those files into the destination directory ..Its like synchronization of 2 directories. 我最近在这个目录中有1.xml,2.xml,3.xml ....有人更新了文件或将新文件添加到该目录中,因此我想将这些文件复制到目标目录中。 2个目录。
For that I have tried below commend 为此,我尝试以下表彰
find home/deployment/server/services/ -type f -mtime 1 | xargs cp /home/application/
and below one also 还有一个
find home/deployment/server/services/ -type f -mtime 1 -exec cp /home/application/
I am not getting any file into destination after updating 1.xml file,So I have added new file 4.xml even that also not updating in destination directory. 更新1.xml文件后,我没有将任何文件导入目标,因此即使在目标目录中也未更新,我也添加了新文件4.xml。
How to process recently updated or newly added multiple files. 如何处理最近更新或新添加的多个文件。
Thanks in advance. 提前致谢。
Short answer: use xargs to mv the "find" directory into another directory 简短答案: 使用xargs将“查找”目录转换为另一个目录
Long answer: As I recall (not tested) for exec syntax is 长答案:我记得(未经测试) exec语法是
find . -type f --mtime 1 -exec cp {} /destination/path/ +
"{}" is an argument which came from command "find" “ {}”是来自命令“ find”的参数
For xargs 对于xargs
find . -type f --mtime 1 | xargs -0 -I {} cp {} /destination/path/
I do this often but use \\; 我经常这样做,但使用\\; instead of + and usually -cnewer rather than -mtime.
而不是+,通常是-cnewer而不是-mtime。
\\; \\; executes the cp command on files individually instead of as a group.
对文件单独而不是成组执行cp命令。 + executes as a group with as many paths as xterm will take.
+与xterm将采用的路径一样,作为一个组执行。 It may do this multiple time if there are a lot of files.
如果有很多文件,它可能会多次执行此操作。
the \\ in front of the ; \\前面的\\; option is required or bash will think it is the end of the command.
选项是必需的,否则bash会认为这是命令的结尾。
find ./ -mtime -1 -exec cp {} /path/ \; -print
Use the -print at the end to get a list of the files that were copied. 最后使用-print获取已复制文件的列表。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.