grep is always recursive

Lorenzo Luengo lluengo at dgeo.udec.cl
Tue Jan 27 20:45:35 UTC 2009


Hal Burgiss wrote:
> On Sat, Jan 24, 2009 at 08:51:49PM -0700, Smoot Carl-Mitchell wrote:
>   
>> You do not happen to have a directory called "-r" in your home
>> directory.  That would cause the problem you are seeing.
>>     
>
> BINGO! That was indeed it. I never would have thought to look for
> that. Excellent work! Thanks all.
>
>   
huuuh

is it a bug?? or a feature??

I made a test with the following directory structure:
./test/
./test/-r/
./test/1/
./test/2/
./test/3/

Then populated it with some files

echo "lala" > 1/1
echo "lala" > 2/1
echo "lala" > 3/1

Then i did:
$ grep "lala" *

1/1:lala
2/1:lala
3/1:lala
$

Then i renamed that directory

mv ./-r ./.-r

$ grep "lala" *
$

Nothing.

The problem comes from the bash * expansion that makes grep see that 
filename as an option. Is it a bash problem? Is it a grep problem?? 
Don't know...

Should it be reported to anyone?

-- 
Lorenzo Luengo Contreras
Administrador de Sistemas DGEO
Universidad de ConcepciĆ³n
ConcepciĆ³n - Chile
+56-41-2207277





More information about the ubuntu-users mailing list