Link to home
Start Free TrialLog in
Avatar of dwcronin
dwcroninFlag for United States of America

asked on

how to output lines of a text file surrounding a certain pattern

I have a bunch of Fortran files and they all have "common blocks" for their variables.  What Unix command do I need to type
to print out the 10 (this is an arbitrary number) above and the 10 lnes (arbitrary) below where the word "DATAPOOL"
appears in all of my files?  I'm looking for something like "grep ... | awk ... > MyVariableList.txt" but I don't remember unix very well.

ASKER CERTIFIED SOLUTION
Avatar of cjjclifford
cjjclifford

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cjjclifford
cjjclifford

oops, you wanted above and below...

grep -A 10 -B 10 DATAPOOL filename