this question has answer here:
i'm trying result of call
tmp=$(find /mydir/ -type f -mmin +1440 | xargs rm -f) m=$? unfortunately, if /mydir/ doesn't exist, result of $? still '0', there not problem. i'd not '0' if find returns nothing.
how should do?
due link:
bash version 3 introduced option changes exit code behavior of pipelines , reports exit code of pipeline exit code of last program return non-zero exit code. long none of programs following test program report non-zero exit code, pipeline report exit code of test program. enable option, execute:
set -o pipefail then
tmp=$(find /mydir/ -type f -mmin +1440 | xargs rm -f) m=$? will behave differently , recognize error. see previous post on stackoverflow
best,
jack.
Comments
Post a Comment