How can I grep a directory for lines that contain "Foo", but only get matches when the next line also contains "Bar"?
|
|
Grep itself doesn't seem to support it, use pcregrep instead:
Got:
|
|||||
|
|
Using
The first EDIT: As manatwork pointed out, there are some problematic cases to be observant of. Although an interesting challenge, due to |
|||||||||||
|
|
@warl0ck pointed me in the right direction with This seems to work for me.
|
|||
|
|
|
With a
To use it :
The Note : this is sorted by alphabetical order. More infos of useful grymoire.com have really good stuff about |
|||||||
|
|
With awk:
(general note about awk limitation: beware that if some file names may contain "=" characters, you'll need to pass them as |
|||
|
|
|
While I prefer Nathan's solution using
Options explanation:
EDIT : This version prints out entire matched lines
|
||||

