Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.