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

Re: Strange 'find' result



In article <[🔎] Pine.LNX.3.96.990216172814.273B-100000@Johann>,
Johann Spies <jhspies@futurenet.co.za> wrote:
>On Mon, 15 Feb 1999, Mitch Blevins wrote:
>> In foo.debian-user, you wrote:
>> > $ find /cdrom -iname wx*
>> > $ find /cdrom -iname wxx*
>> > /cdrom/debian/hamm/hamm/binary-i386/libs/wxxt1_1.66d-2.deb
>> > 
>> > Why does the first 'find' query give no results?
>> 
>> Are you quoting the argument to avoid shell expansion?
>> 
>> $ find /cdrom -iname 'wx*'
>
>No.  I just did it as it was printed above.
>
>Today is another day.  I did the same thing and here is the result:
>(I was in my home directory as I was yesterday)
>
>jhspies@Johann(8)$ find /cdrom -iname wx*
>find: paths must precede expression
>Usage: find [path...] [expression]

If you enter this command, and you have files beginning with "wx" in
the current directory, the shell will replace the "wx*" word with the
names of those files.

So if you had, for instacne, files "wxa" and "wxb" in your current
directory, the shell would actually execute:

find /cdrom -iname wxa wxb

which command will indeed produce the error you have shown us.

>jhspies@Johann(9)$ cd /
>jhspies@Johann(10)$ find /cdrom -iname wx*
>/cdrom/debian/hamm/hamm/binary-i386/doc/wxhelp_1.66d-2.deb
>/cdrom/debian/hamm/hamm/binary-i386/libs/wxxt1_1.66d-2.deb

This command succeeded because you changed to the root directory,
which clearly does not have files beginning with 'wx' in it. In this
case, bash leaves the expansion alone, assuming that that's what you
meant.

You can see this behaviour by prefixing the "find" command with
"echo".

This is a bash "feature". Some shells, such as tcsh, would give you
"wx*: file not found" or somesuch for your second command (which is
either more helpful or less useful depending on your point of view, I
suppose).

>Anyhow, it is not a problem for me.  I was just curious on why the strange
>result.  Now I am wondering why I did not get the same result today?

Presumably the first time you had only one matching file in your CWD,
and hence produced a syntactically correct find command, although it
wasn't the one you intended to give.

SRH
-- 
Steve Haslam            Validation Engineer, ARM Limited, Cambridge, England
almost called it today, turned to face the void along with the suffering
and the question- "Why am I?"                                  [queensrÿche]


Reply to: