3 ms·
Both of these are valid: -exec <command> <args> {} + -exec <command> <args> {} <args> \; (The backslash is unnecessary for +) The first one, the one used
by Izkata 7y ago
Both of these are valid:
-exec <command> <args> {} +
-exec <command> <args> {} <args> \;
(The backslash is unnecessary for +)
The first one, the one used here, acts like xargs. The second one executes <command> individually for each file found. Because the "+" version continually adds files to it, it must be last, but the "\;" version doesn't have that restriction since it's a single substitution. Just to be clear with an example:
$ ls
one three two
$ find . -exec echo 11 {} 22 \;
11 . 22
11 ./two 22
11 ./three 22
11 ./one 22
$ find . -exec echo 11 {} 22 +
find: missing argument to `-exec'
$ find . -exec echo 11 {} +
11 . ./two ./three ./one
Most people seem to only learn one of them, even getting them mixed up. For example, I had learned the "\;" one and for years thought they both acted like that, with "+" simply being an alternate end-of-command identifier to avoid needing to escape the semicolon.