Super User is a question and answer site for computer enthusiasts and power users. 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 have word like initialize_my_var: in sample.php

and I included three library files, take it as a.php, b.php, c.php ,

I really don't know where my label(initialize_my_var: ) definition is present in my library

files, is it possible with a pattern matching string to find which library file really have the exact term "initialize_my_var:" , I'm really looking for an exact pattern match.

share|improve this question

Give this a try:

grep initialize_my_var a.php b.php c.php

It will show you which file(s) and what the line number(s) are.

share|improve this answer
fgrep or grep -f is a little faster in general since there is no regexp matching. For three, likely small files, grep or fgrep won't matter too much, but if these three also include other files that may want to be searched (like an additional hundred), then fgrep might have an advantage. – Arcege Jan 31 '11 at 17:14
@Arcege: True. For GNU and BSD grep, it's grep -F (lowercase -f specifies a file to read patterns from). – Dennis Williamson Jan 31 '11 at 17:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .