I want to run the command
find some/path -exec program \\{} \\;
but I want the find command to quit as soon as the command
I think it is not possible to achieve what you want, only with find -exec
.
The closest alternative would be to do pipe find
to xargs
, like this:
find some/path -print0 | xargs -0 program
or
find some/path -print0 | xargs -0L1 program
This will quit if program terminates with a non-zero exit status
print0
is used so that files with newlines in their names can be handled -0
is necessary when -print0
is used L1
tells xargs
program to execute program with one argument at a time (default is to add all arguments in a single execution of program)If you only have sane file names, you can simplify like this:
find some/path | xargs program
or
find some/path | xargs -L1 program
Finally, If program takes more than one argument, you can use -i
combined with {}
. E.g.
find some/path | xargs -i program param1 param2 {} param4