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 cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Usage of grep or awk

Status
Not open for further replies.

matt1

Mechanical
Joined
Sep 3, 2002
Messages
1
Location
US
How would I grep for the pattern

"S T R E S S 1" from a file
and print the lines following the pattern etc upto to a blank line or

another pattern say "S T R E S S 5"

In other words print the lines between patterns
"S T R E S S 1" and " S T R E S S 5"

The File is as follows

S T R E S S 1
xyc
yzn nn
bx ccc-next line is a blank line

S T R E S S 5
ccc

ddfdsa


ddd

EOF

How would I use awk or any other pattern matching
utilities within UNIX to do this

Thanks

 
awk is your best for this.

awk '/STRESS1/,/STRESS5/ my_file
 
OOPS! forgot a quote.

awk '/STRESS1/,/STRESS5/' my_file
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top