when I perform
find /tmp -name something
find command not find the something word under /tmp
echo $?
I get $?=0
it's OK
but how to enable Exit status diff then 0 when find command not find the something word?
|
when I perform
find command not find the something word under /tmp
I get $?=0 it's OK but how to enable Exit status diff then 0 when find command not find the something word? |
|||
|
|
|
Here is a one-liner that I believe does what you want:
The return status will be If you also need to capture the output of |
|||
|
|
|
It's not possible. Find returns 0 if it exits successfully, even if it didn't find a file (which is a correct result not indicating an error when the file indeed doesn't exist). To quote the find manpage
Depending on what you want to achieve you could try to let find
|
|||
|
|
|
It is not only |
||||
|
|
|
Here's a little script I called
Here's the command-line output:
Then, for a result where find had errors but found files:
Then, if you want the list of files you can make use of |
|||
|
|
|
I feel that this is the most concise and direct method:
|
|||||||||||||
|