Mark Galeck
Mark Galeck

Reputation: 6395

why doesn't recursive grep appear to work?

The man page for grep says:

-r, --recursive
          Read all files under each directory, recursively

OK, then how is this possible:

# grep -r BUILD_AP24_TRUE apache
# grep BUILD_AP24_TRUE apache/Makefile.in
@BUILD_AP24_TRUE@mod_shib_24_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \
(...)

Upvotes: 1

Views: 1454

Answers (1)

John1024
John1024

Reputation: 113924

There are two likely causes this type of problem:

  1. grep is aliased to something that excluded the files you were interested in.

  2. The file of interest is in a symlinked directory or is itself a symlink.

In your case, it appears to be the second cause. One solution is to use grep -R in place of grep -r. From man grep:

   -r, --recursive
          Read  all files under each directory, recursively, following symbolic
          links only if they are on the command line.  Note that if no file
          operand is given, grep searches the working directory.
          This is equivalent to the -d recurse option.

   -R, --dereference-recursive
          Read all files under each directory, recursively.
          Follow all symbolic links, unlike -r.

Upvotes: 3

Related Questions