bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: grep recursive problem


From: Chuck Swiger
Subject: Re: grep recursive problem
Date: Thu, 19 Oct 2006 12:06:03 -0700

On Oct 19, 2006, at 6:04 AM, dan1 wrote:
I am trying to find text in some files and it works fine when I type the following command from inside the directory where the file contains the text searched for:
grep -r -i i80word *.php

However if I go one directory up and type the same command, there is no result at all, like if the '-r' otion would not be taken into account. I tried --recursive but the result is the same.

I think that this is a bug, could you please confirm ?

It's not a bug; this is user-error. Unless you've got directories named something.php, using -r together with a wildcard which does not match anything will not do what you expect. Try:

        grep -i i80word */*.php

...or...

        find /some/path -name *.php | xargs grep -i i80word

...instead.  The manpage provides a reasonable explanation:

       -d ACTION, --directories=ACTION
If an input file is a directory, use ACTION to process it. By default, ACTION is read, which means that directories are read just as if they were ordinary files. If ACTION is skip, direc- tories are silently skipped. If ACTION is recurse, grep reads all files under each directory, recursively; this is equivalent
              to the -r option.

--
-Chuck







reply via email to

[Prev in Thread] Current Thread [Next in Thread]