find behaviour differs depending on directory
Kevin P. Fleming
kpfleming at linuxfromscratch.org
Fri Aug 27 10:09:46 PDT 2004
Laurens Blankers wrote:
> [laurensb at beta] </usr/src/linux-22.214.171.124/net> find -name *.ko
> [laurens at beta] </usr/src/linux-126.96.36.199/net/ipv4> find -name *.ko
> find: paths must precede expression
> Usage: find [path...] [expression]
You are using incorrect syntax. The first example works because the
directory you are in does not contain any *.ko files, so when the shell
(bash) tries to expand *.ko into a filename list it can't, so "*.ko" is
passed to find verbatim.
The second example fails because the directory _does_ contain *.ko
files, so your command is turned into:
find -name foo1.ko foo2.ko foo3.ko .... etc.
This happens because you didn't "protect" the asterisk character by
quoting it, so the shell is processing it, not the find command.
To do what you want, you should use:
find -name \*.ko
More information about the lfs-support