bug-findutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is there a way to let find return non-zero when nothing is found?


From: Eric Blake
Subject: Re: Is there a way to let find return non-zero when nothing is found?
Date: Mon, 11 Nov 2019 10:05:17 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]