Re: Reg.. find command not working as expected in Ubuntu...

raf <[email protected]>
Newsgroups gmane.comp.gnu.findutils.bugs
Message-ID <[email protected]>
On Mon, Dec 04, 2023 at 07:37:10AM +1100, raf <[email protected]> wrote:

> On Sat, Dec 02, 2023 at 03:44:19PM +0000, Mannem Anil kumar <[email protected]> wrote:
> 
> >   Dear Concern,
> > As i was exploring Linux related commands, i have executed the
> > following command in terminal. Where that file is not existed and
> > find command not says that file is not found.
> > After checking the previous command execution status ($?=0) it shows success. Can you please check it.
> > Same status for file available or not available. Checked with SH and BASH shells. Same wrong output.
> > Note: If file is there, it is displaying that location ($? =0).
> > 
> > Regards,
> > Anil Kumar
> 
> Hi. That sounds like the correct behaviour. find doesn't report files that
> aren't there. It reports files that it finds. If you search for a file
> named foo with "find . -name foo", and foo doesn't exist, there will
> be no output (because no matching file was found), and the exit status
> will be zero to indicate that no errors were encountered during the search.
> The exit status on Linux commands indicate whether or not an error occurred.
> This is the case for all commands, not just find. Not finding a file is not
> an error.
> 
> cheers,
> raf

Oops. Apart from the "test" program. It's exit status isn't an error code.
It is a logical value. And grep. But they are the only examples I can think
of right now where the exit status isn't used to indicate the presence or
absence of an error.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.