2013-03-10 131 views
4

我碰到使用中的例子find命令如下(它复制的目录结构中的某些地方)来到%p和%P之间的区别是什么find命令

find olddir -name script.sh -printf "%p\0" -printf "newdir/%P\0" | xargs -0L2 cp -n 

我与区别不明确%p和%p 之间我发现阅读的手册页不说太多

%p  File's name. 
%P  File's name with the name of the command line argument under which it was found removed. 

是什么

我很困惑什么%p和%p之间的区别这意味着由

%P  File's name with the name of the command line argument under which it was found removed. 

回答

5

你甚至尝试过吗?在您的示例中,%p将打印包含olddir部分的文件,%P将打印该文件。几乎完全是文档所说的。简单示例:

$ ls -R 
.: 
dir/ 

./dir: 
file 
$ find dir -name file -printf '%p\n' 
dir/file 
$ find dir -name file -printf '%P\n' 
file 
+0

我也无法理解您的解释 – 2013-03-10 17:04:50

+1

我添加了一个示例。我仍然不明白你为什么不尝试。 – 2013-03-10 17:07:12

+0

我明白了你的观点让我更具体我已经尝试了我感到困惑的是在查找的man页面中使用的语言,它说'文件名与它被发现删除的命令行参数的名称'相关,因为在%p它说在这两种情况下的文件名,它只是在一个情况下打印文件名与目录名称和一个情况下没有目录名,所以两种类型的文件名 – 2013-03-10 17:14:38