What is the difference between% p and% P in find command

I came across using the find command in the example as follows (it copies the directory structure somewhere)

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

I don’t understand the difference between% p and% P. I read the search man page, which doesn’t say much.

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

what is the difference between% p and% P

I am confused by what this means

  %P File name with the name of the command line argument under which it was found removed. 
+4
source share
1 answer

Have you even tried? %p in your example prints the file, including the olddir part, and %p prints it without. Quite exactly what the documentation says. A simple example:

 $ ls -R .: dir/ ./dir: file $ find dir -name file -printf '%p\n' dir/file $ find dir -name file -printf '%P\n' file 
+5
source

All Articles