-4

I have seen find commands as follows, and wonder on the difference between them.

find . -exec COMMAND {} \;
find . -exec COMMAND {} \+
find . -exec COMMAND {} +
Vera
  • 1,223
  • Do \+ and + behave the same way? – Vera Oct 24 '21 at 05:40
  • 1
    \+ in most shells is the same as '+' or "+", backslash is a quoting operator in the shell syntax, so you end up with a quoted +. + being not a special character in the shell syntax, quoting is unnecessary, so it's the same as +. It's different for ;. Where \;, ';' or ";" are three ways to pass a literal ; to find, but unquoted ; is special in the shell syntax: it's used to separate commands. – Stéphane Chazelas Oct 24 '21 at 06:18
  • Is + a special character in gnu bash? – Vera Oct 24 '21 at 06:38

1 Answers1

-3

There are two syntaxes for find exec.

find . -exec [cmd] {} \;

{} Is a placeholder for the result found by find

; Says that for each found result, the command cmd is executed once with the found result.

It is executed like this: cmd result1; cmd result2; ...; cmd result N

find . -exec [cmd] {} \+

{} Is a placeholder for the result found by find

+ Says that for all found results, the command cmd is executed with all the found results.

It is executed like this: cmd result1 result2 ... result N

when we should use find exec ; other than +

The tool run by -exec does not accept multiple files as an argument

Running the tool on so many files at once might use up too much memory

We want to start getting some results as soon as possible, even though it will take more time to get all the results

DOS HASAN
  • 118
  • 2