简体   繁体   English

复制与不同文件夹中的名称匹配的文件

[英]Copy files matching a name in different folders

I am using 我在用

find ../../ -type f -name <filename>*.PDF -print0 | xargs -0 cp --target-directory=Directory name with path>;

but it is copy only one file. 但它只能复制一个文件。 It doesn't copy all files which is having same name. 它不会复制具有相同名称的所有文件。 I need number of files to be searched and copied which is having same name but it it created on different date and different folder. 我需要搜索和复制具有相同名称的文件数量,但是它是在不同的日期和不同的文件夹中创建的。 how to solve this issue. 如何解决这个问题。 I have already created lot's more I am facing the problem in this regard. 我已经创造了更多的东西,我在这方面面临的问题。

This will give you the duplicate files. 这将为您提供重复的文件。 Once you have the name, you can find them and delete them using your script: 一旦有了名称,就可以使用脚本find并删除它们:

for i in `find .|grep pom.xml`; do 
   basename $i;
done |sort|uniq -c|sort -n|cut -b9-

PS: everyone's in a hurry. PS:大家都很着急。 Adding urgency to your posts is usually frowned upon in StackOverflow, and you might prompt the opposite reaction 在StackOverflow中通常不会为您的帖子增加紧迫性,您可能会提出相反的反应

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM