简体   繁体   English

如何在Solaris的另一个目录中复制最近更新的多个文件

[英]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.

相关问题 使用bash脚本将两个最新文件复制到另一个目录 - Copy two most recent files to another directory using bash script 如何将前10个最新文件从一个目录复制到另一个目录? - How to copy the top 10 most recent files from one directory to another? 如果文件不在另一个目录中,则将文件复制到目录 - Copy files to directory if they are not in another directory 如何使用 bash 将多个版本号不同的文件从一个目录复制到另一个目录? - How to copy multiple files with varying version numbers from one directory to another using bash? 如何将具有相同后缀的所有文件复制到另一个目录? -Unix - How to copy all the files with the same suffix to another directory? - Unix 如何将文件从 linux 目录复制到另一个给定长度参数 - How to copy files from a linux directory to another given a length parameter 如何在Linux中将具有特定扩展名的文件从一个目录复制到另一个目录 - How to copy files with a particular extension from one directory to another in linux 如何将目录及其子目录中的所有文件复制到另一个目录? - How to copy all files from a directory and its subdirectories to another dir? 如何使用cp从不同的目录复制多个文件? - How to copy multiple files from a different directory using cp? 如何使用多个正则表达式在Solaris中查找文件 - How to find files in Solaris using multiple regular expressions
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM