简体   繁体   中英

gnu find weirdness: filename wildcards broken?

find is behaving as if I am NOT quoting wildcards in -name patterns, but I AM quoting them:

/var/log # find . -name '*.gz'
find: paths must precede expression: dmesg.1.gz
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]

/var/log # find . -name dmesg.1.gz
./dmesg.1.gz
/var/log # echo '*.gz'
*.gz

I know this used to work correctly - and it still does on other machines of mine. What could cause this behavior?

My bash version: GNU bash, version 4.2.37(1)-release (i486-pc-linux-gnu)

My find version: find (GNU findutils) 4.4.2

/proc/version: Linux version 3.2.0-4-686-pae (debian-kernel@lists.debian.org) (gcc version 4.6.3 (Debian 4.6.3-14) ) #1 SMP Debian 3.2.60-1+deb7u3

Tranferring comments to answer.

Have you checked for aliases, functions or scripts called find that mishandle the arguments they're given?

Only to the extent that which find returns /usr/bin/find as expected.

That's useful … try alias to see aliases, and … is it typeset -f to see functions? (Yes, either typeset -f or — the native Bash way instead of Korn shell compatibility way — declare -f .) Since find is behaving differently from echo , there must be something about find that is odd. You could also try:

command find . -name '*.gz'

which should run the command rather than an alias or function — or, indeed:

/usr/bin/find . -name '*.gz'

That did it - I had a find() function defined, and command find works as expected. Found it with set | grep find set | grep find .

Glad that solved it!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM