October 5th, 2003, 01:15 PM
using grep to find and not find strings
I'm trying to search php files in a directory for their include files except those that have the strings "header" or "footer".
This is what I'm using so far with no luck:
grep -Ers '((include|require)_once|include|include_files).*[^(footer|header)].*' directory_name
I guess my question is how do I use the ^ to do a no match on strings. I can't seem to find the right documentation or examples anywhere.
I'm using GNU grep version 2.4.2...Please help. Thanks.
October 5th, 2003, 01:29 PM
I would do it in two steps:
1. find all includes
2. remove the headers and footers.
... adjust to your needs
grep -Eir . 'include(_files)?|require(_once)?' | grep -viE 'header|footer'
("grep -v" is find "not")
October 5th, 2003, 02:13 PM