Solved Understanding the command find with the -exec parameter.

Hi,
the command:
# find /tmp -exec /root/bin/test.sh {} \;
with the /root/bin/test.sh script:
Code:
#!/bin/sh
#
echo "$1"
exit 1

Should stop at the first file found.
From the find() page:
-exec utility [argument ...] ;
True if the program named utility returns a zero value as its
exit status.

Why the command doesn't stop ?
--
Regards
Maurizio
 
[…] True if the program named utility returns a zero value as its exit status. […]
This refers to the value the primary evaluates to. For example​
Bash:
find /tmp -exec /root/bin/test.sh '{}' ';' -and -delete
will not delete any file because your script returns a non‑zero exit status. What you want is, taking account of short‑circuit evaluation,​
Bash:
find /tmp -exec /root/bin/test.sh '{}' ';' -or -quit
 
Back
Top