Why is there a difference in output between using
find . -exec ls '{}' \+
and
find . -exec ls '{}' \;
I got:
$ find . -exec ls \{\} \+
./file1 ./file2
.:
file1 file2 testdir1
./testdir1:
testdir2
./testdir1/testdir2:
$ find . -exec ls \{\} \;
file1 file2 testdir1
testdir2
./file2
./file1
This might be best illustrated with an example. Let’s say that
findturns up these files:Using
-execwith a semicolon (find . -exec ls '{}' \;), will executeBut if you use a plus sign instead (
find . -exec ls '{}' \+), as many filenames as possible are passed as arguments to a single command: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.