简体   繁体   English

如何查找然后复制找到的文件,Linux

[英]How to find then copy found files, linux

I'm trying to search a directory for all of its wsdl files and then copy them to another location. 我正在尝试搜索所有wsdl文件的目录,然后将其复制到另一个位置。 Right now I'm using xargs since, if I understand correctly, it takes the output of one command and uses it as the arguments of the piped command. 现在,我正在使用xargs因为如果我理解正确,它将使用一个命令的输出并将其用作管道命令的参数。 However, I keep getting prompted that a file is not a directory and thus the command fails. 但是,我一直提示文件不是目录,因此命令失败。 I'm fairly new to linux so maybe someone can tell me why this is happening and how to fix it? 我对linux还是很陌生,所以也许有人可以告诉我为什么会这样以及如何解决它?

Here's my command: 这是我的命令:

find VMware-vSphere-SDK-5.5.0-1284541/ -iname "*.wsdl" | xargs cp -i '{}' /home/jaayers

Keeps throwing this: 不断抛出这个:

cp: target 'VMware-vSphere-SDK-5.5.0-1284541/SDK/eam/wsdl/eam.wsdl' is not a directory

EDIT: 编辑:

So changing the command to 因此将命令更改为

find VMware-vSphere-SDK-5.5.0-1284541/ -iname "*.wsdl" | xargs cp -i {} -t /home/jaayers

will copy the files but still prints this message 将复制文件,但仍打印此消息

cp: cannot stat '{}': No such file or directory

so even though it's doing what I want it to do I assume it's not the proper way to achieve the desired function, perhaps someone can suggest a better way to accomplish this? 因此,即使它正在执行我想要的操作,我仍认为这不是实现所需功能的正确方法,也许有人可以建议一种更好的方法来实现此目的?

您必须位于该文件夹中,或者给出我认为的绝对路径,例如“ /home/user/VMware-vSphere-SDK-5.5.0-1284541/”。

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

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