I would like to use find
on a directory structure to exit if at least
one file exists with a target condition, because this will lead to a failure of the rest of a shell script.
Since this shell script is intended to run on big directory structures I would like to exit of it as soon as possible.
For example I would like to do:
find . -name "test" -prune
# if "test" file found, just exit immediately
if [ $? -eq 0 ] ; then
echo error... >&2
exit 2
fi
...continuation of shell script
But -prune
is always evaluated to true.
What is the more efficient way to write a find
expression to achieve
this kind of short circuit find
?
I would like to use as standard as possible Bourne shell constructs and avoid the use of any temporary file.