Even when /tmp
has no file called something
, searching for it with find
will return 0:
$ find /tmp -name something
$ echo $?
0
How can I get a non-zero exit status when find
does not find anything?
find
Even when /tmp
has no file called something
, searching for it with find
will return 0:
$ find /tmp -name something
$ echo $?
0
How can I get a non-zero exit status when find
does not find anything?
Best Answer
The return status will be
0
when something is found, and non-zero otherwise.EDIT: Changed from
egrep '.*'
to the much simplergrep .
, since the result is the same.