scp 通过 Xargs 定位输出
我想制作一个locate 输出的文件列表。 我想要 scp
获取该列表。
我不确定语法。 我对伪代码的尝试
locate labra | xargs scp {} [email protected]:~/Desktop/
如何将文件移动到目的地?
I want to make a list of files of locate's output.
I want scp
to take the list.
I am not sure about the syntax.
My attempt with pseudo-code
locate labra | xargs scp {} [email protected]:~/Desktop/
How can you move the files to the destination?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
xargs 通常会接受命令行中能够容纳的尽可能多的参数,但是使用 -I 它突然只需要一个。 GNU Parallel http://www.gnu.org/software/parallel/ 可能是更好的解决方案:
既然您正在查看 scp,我可以建议您也查看一下 rsync 吗?
xargs normally takes as many arguments it can fit on the command line, but using -I it suddenly only takes one. GNU Parallel http://www.gnu.org/software/parallel/ may be a better solution:
Since you are looking at scp, may I suggest you also check out rsync?
通常,{} 是查找主义:
其中 {} 是查找正在处理的当前文件。
您可以使 xargs 的行为类似于:
但是,您很快就会注意到它多次运行命令,而不是一次调用 scp。
因此,在您的示例的上下文中:
请注意 {} 周围的单引号,因为它对于其中包含空格的路径很有用。
Typically, {} is a findism:
Where {} is the current file that find is working on.
You can get xargs to behave similar with:
However, you'll quickly notice that it runs the commands multiple times instead of one call to scp.
So in the context of your example:
Notice the single quotes around the {} as it'll be useful for paths with spaces in them.