Find -exec {} + argument list limit

argumentsfindxargs

I know that when the maximum argument list size is reached, xargs keeps creating new lists until all of the files are included;

but does find -exec <command> {} + do the same thing or will it not work if the size of the list exceeds the output of getconf ARG_MAX?

Best Answer

Yes, find -exec ... {} + runs the given command as many times as necessary to accommodate all the arguments without exceeding the maximum argument list size in each invocation. This is specified by POSIX:

If the primary expression is punctuated by a <plus-sign>, the primary shall always evaluate as true, and the pathnames for which the primary is evaluated shall be aggregated into sets. [...] An argument containing only the two characters "{}" shall be replaced by the set of aggregated pathnames, with each pathname passed as a separate argument to the invoked utility in the same order that it was aggregated. The size of any set of two or more pathnames shall be limited such that execution of the utility does not cause the system's {ARG_MAX} limit to be exceeded.

(emphasis mine).

Related Question