Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm writing a module for drupal. Its functionality is contingent on the directory name, certain file names, and function names being identical.

I'm troubleshooting now, and I wanted to to a search to see that I had an identical string in all the places I needed it to be, but I realized I would be missing the directory name and filename! Is there a way to do a grep or something that would search all that information?

For example, if my module was named string, I would need

  function string_function1() {...}
  function string_function2() {...}

If I did my everythinggrep string . and I saw

  function string_function1() {...}
  function string_function2() {...}

I would know that I had misnamed my module file.

share|improve this question
Would the file actually be string.module? – k.parnell Oct 6 '11 at 18:57
@k.parnell Yes. The directory name, the first part of the file name, and the first parts of function names must all be identical. – user394 Oct 6 '11 at 20:10
up vote 5 down vote accepted

Not in a single statement, but in two statements:

For searching in text-files:

grep -RI "string" directory/*

For finding file-names:

find directory -type f -name "*string*" -ls
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.