2013-03-10 108 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