如何通过查找结果CP使得具有空格的文件名工作 [英] How To Pass Find results to CP such that File Names with Spaces work

查看:166
本文介绍了如何通过查找结果CP使得具有空格的文件名工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用具体的附件文件复制到不同的目录中的相对路径preserved。从最初的顶级路径,我呼吁:

I'm trying to copy files with specific attachments to a different directory with their relative paths preserved. From the original top path I am calling:

cp --parents `find . -name \*.pdf -print` /new_path/

我相信这个工程;然而,只有当找到该文件的名称中没有空格。

I believe this works; however only if the file found has no spaces in the name.

我也试过:

cp --parents `find . -name \*.pdf -print0` /new_path/

因为没有换行字符CP接收错误的名称这不明明工作。

This doesn't work obviously because without the new line character cp receives the wrong name.

是否有可能围绕找到报价的结果?

Is it possible to surround the find result with quotes ?

推荐答案

试试这个:

find . -name \*.pdf -print0 | xargs -0 -n 1 -Ifoo cp --parents foo /new_path/

或者

find . -name \*.pdf -exec cp --parents {} /new_path/ \;

这篇关于如何通过查找结果CP使得具有空格的文件名工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆