Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GNU find -exec command {} ; vs -exec command {} +

Tags:

syntax

linux

gnu

Can anyone please explain the difference between the following two GNU find options for the -exec argument:

  1. find -exec command {} ;
  2. find -exec command {} +

The man page does a good example of explaining that "one might prefer the -exec ... + or better the -execdir ... + syntax for performance and security reasons" but I can't seem to wrap my head around the basic premise of ; vs +

Any help is welcome and appreciated!

like image 965
lostipod Avatar asked Jul 20 '26 09:07

lostipod


1 Answers

The ; syntax executes the command for each single match. The + command runs the command with a long list of matches as arguments to the command.

For example:

$ find
.
./a.txt
./b.png

$ find . -exec echo {} \;
.
./a.txt
./b.png

$ find . -exec echo {} +
. ./a.txt ./b.png
like image 116
choroba Avatar answered Jul 22 '26 22:07

choroba