[ale] weird "find" behavior
Brian Pitts
brian at polibyte.com
Sun Dec 2 01:27:56 EST 2007
Jim Popovitch wrote:
> On Sun, 2007-12-02 at 00:24 -0500, Greg Freemyer wrote:
>> On Dec 1, 2007 6:42 PM, Jim Popovitch <yahoo at jimpop.com> wrote:
>>> I'm seeing some find weirdness. On both Ubuntu Etch and RH4ES, if I do
>>> the following I can locate files:
>>>
>>> find /usr/include/ -type f -name *.c
>>>
>>> But if I do this, I find nothing:
>>>
>>> find /usr/include/ -type f -name *.h
>>>
>>> However if I do this, I find files:
>>>
>>> find /usr/include/ -type f -name "*.h"
>>>
>>> WTF?
>>>
>>> -Jim P.
>> If the current directory has no *.c files, then your first command
>> works by chance.
>>
>> If it has some *.h files, then it fails due to standard shell
>> expression expansion.
>>
>> The "*.h" syntax will always work.
>
> Right, but why does *.c work BUT not *.h, both without shell expansion
> (which is what my WTF was all about).
>
> -Jim P.
*.c works because there are no files ending in .c for the shell to
expand that expression to. *.h fails because there are. Like Greg said
"If the current directory has no *.c files, then your first command
works by chance.
If it has some *.h files, then it fails due to standard shell
expression expansion."
In other words,
ls | grep "\.c"
returns nothing, whereas
ls | grep "\.h"
shows something.
You can verify that shell expansion is taking place using strace.
-Brian
More information about the Ale
mailing list