Tue 31 Mar 2009 11:21:14 AM UTC, original submission:
-execdir {} + and -execdir {} \; give identical results when -exec {} + and -exec {} \; give different results. For example:
If I construct a directort structure such that:
user@host:~$ ls -R
.:
dir1
dir2
dir3
./dir1:
file1a
file1b
file1c
./dir2:
file2a
file2b
file2c
./dir3:
file3a
file3b
file3c
-exec {} + will run a command on each file simultaneously:
user@host:~$ find . -iname 'file*' -exec echo {} +
./dir2/file2a ./dir2/file2b ./dir2/file2c ./dir3/file3c ./dir3/file3a ./dir3/file3b ./dir1/file1b ./dir1/file1a ./dir1/file1c
Whereas -exec {} \; will echo each file individually.
-execdir {} + runs the echo command on each file individually (from within the subdirectories) and not (as I would have thought is meant to be the case) three times, once per subdirectory:
user@host:~$ find . -iname 'file*' -execdir echo {} +
./file2a
./file2b
./file2c
./file3c
./file3a
./file3b
./file1b
./file1a
./file1c
The output from find . -iname 'file*' -execdir echo {} \; is identical.
Appologies if I'm not being clear or if I'm making a basic error somewhere. I'm pretty new to using find and am not a complete expert using the shell.This is version 4.4.0 of find
|