On 11/11/19 3:45 AM, Peng Yu wrote:
Hi,
Sometimes, I'd like to know whether there is nothing found. Is there a
way to let find return none-zero when nothing is found? Thanks.
Not built in to find directly, but you can emulate it via a number of
means, such as having find touch a witness file in addition to whatever
else you were having it do when it finds any file, then testing if the
witness file exists afterwards. If the action you are having find
perform is printing a list of files, it's even simpler: check whether
output was produced.
Maybe it's worth adding something into find to do what you're asking,
but I don't know that I would be the one to write such a patch. We'd
also have to be very clear about what the semantics are (is it a command
line option, or would it be a predicate that you can place alongside
other predicates where position matters).
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org