Using semicolon (;) vs plus (+) with exec in find

This might be best illustrated with an example. Let’s say that find turns up these files:

file1
file2
file3

Using -exec with a semicolon (find . -exec ls '{}' \;), will execute

ls file1
ls file2
ls file3

But if you use a plus sign instead (find . -exec ls '{}' \+), as many filenames as possible are passed as arguments to a single command:

ls file1 file2 file3

The number of filenames is only limited by the system’s maximum command line length. If the command exceeds this length, the command will be called multiple times.

Leave a Comment