序文:-exec {} \;&の違いを理解しました-exec {} +。私もそのような問題はありませんが、のセマンティクスに興味がありfindます。
終了する場合-execと、引数+の代わりに;、我々は必要でこれを終了するには{} +、たとえば、:
# FreeBSD find
$ find . -type f -exec cp {} /tmp +
find: -exec: no terminating ";" or "+"
# GNU find is even more cryptic:
$ find: missing argument to `-exec'
;これらの例の代わりに使用することは+問題なく動作します(ただし、明らかに他のことを行います)。
POSIXから:
-exec utility_name [argument ...] ;
-exec utility_name [argument ...] {} +... 2つの文字 "
{}" のみを含む引数の直後に続く<plus-sign>のみが、1次式の終わりを区切ります。<plus-sign>の他の使用は、特別なものとして扱われません。
つまり、を使用する+場合、コマンドはで終わる必要があります{} +。
どうしてこれなの?そして、なぜだけで+なく;?最初に私には含まれていたファイル名との競合を避けるためにおそらく考え+ではなく、ファイル名を;作業罰金に思えますか?この制限が恣意的であるとは信じがたいです...
The "-exec ... {} +" syntax adopted was a result ofIEEE PASC Interpretation 1003.2 #210、その詳細が記載されていると記載されています。例:Note that the "+" is only treated as special if it immediately follows "{}". This minimises the chances of causing problems with existing uses of "+" as an argument with "-exec".