[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Reg.. find command not working as expected in Ubuntu...
From: |
raf |
Subject: |
Re: Reg.. find command not working as expected in Ubuntu... |
Date: |
Mon, 4 Dec 2023 07:43:35 +1100 |
On Mon, Dec 04, 2023 at 07:37:10AM +1100, raf <gnu@raf.org> wrote:
> On Sat, Dec 02, 2023 at 03:44:19PM +0000, Mannem Anil kumar
> <mannemanilkumar302@outlook.com> 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.