5

次の例でfindコマンドの使用に出くわしました(ディレクトリ構造をどこかにコピーします)

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

%p と %PI の違いがよくわかりません 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.
4

1 に答える 1

8

あなたもそれを試しましたか?あなたの例では、その部分%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
于 2013-03-10T17:04:19.363 に答える