Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pull two lines with script 1

Status
Not open for further replies.

jestrada101

Technical User
Mar 28, 2003
332
How can I pull two lines with a script based on a grep?

For example, my file will have multiple lines like teh following... in random places... I want to pull "TEST" and the number below it.. how can I do that?

TEST
343000
Randome info...
TEST
454646
More Random info..
TEST
12312312
 
Another way:
awk '/TEST/{print;getline;print}' /path/to/input

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks.. the "awk" command worked. grep -A was not an option with my grep on a Sun box.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top