Judging from the GNU findutils change log it had to be in GNU's find for at least a decade (also longer than that it was part of POSIX) so can it be safely assumed to be supported everywhere now?
Also, are there any good reasons to advocate for xargs
instead in cases where -exec … +
could be used? (Obviously you would use xargs
if you need some of those special parameters like e.g. those for controlling the maximal number of arguments, parallelism, …)
An interesting quote from a part of GNU findutil's documentation:
[find with
-exec … +
] can be less efficient than some uses ofxargs
; for examplexargs
allows new command lines to be built up while the previous command is still executing, and allows you to specify a number of commands to run in parallel. However, thefind ... -exec ... +
construct has the advantage of wide portability. GNU findutils did not support ‘-exec ... +
’ until version 4.2.12 [January 2005]; one of the reasons for this is that it already had the ‘-print0
’ action in any case.
-exec utility_name [argument ...] {} +
is POSIX. What's the question here ? – don_crissti Oct 31 '16 at 21:46-exec … +
as a justification to argue forxargs
instead. (Compare it to like you can't or couldn't ignore IE even when sticking to the various standards in web development.) – phk Oct 31 '16 at 21:48-exec ... {} +
is specified by POSIX. – Wildcard Oct 31 '16 at 22:45xargs
instead in cases where-exec ... +
could be used?" No, there aren't. If you have GNU xargs and GNU find you can use the null byte separator, but if you have GNU find you can also just use-exec ... {} +
. Since usingfind | xargs
without a null byte separator will work in most cases, it's all the more dangerous because beginners will think their code is robust when it isn't. – Wildcard Oct 31 '16 at 23:35