我在一个示例中遇到了 find 命令的使用,如下所示(它将目录结构复制到某处)
find olddir -name script.sh -printf "%p\0" -printf "newdir/%P\0" | xargs -0L2 cp -n
我不清楚 %p 和 %P 之间的区别 我读了 find 的手册页,里面说的不多
%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.
最佳答案
你试过吗?在您的示例中,%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
关于bash - find 命令中的 %p 和 %P 有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15324932/