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!

AWK condition problem

Status
Not open for further replies.

parbhani

Technical User
Jul 3, 2002
125
GB
Hi all ,

I have a awk like this ,

awk '/Column_name/,/^ *$/ { print $0 }' tab.txt

Simply, select all lines between ( including ) the line containing the word 'Column_name' and subsequent blank line.

What I want if lines between ( and including ) line containing 'Column_name' and "subsequent blank line OR a line containing word 'ENDOFMESSAGE' ", how to do that ?
Means output should start with a line containing word 'Column_name' and end with either a blank line or a line containing word 'ENDOFMESSAGE' .


Regards
 
Have you tried something like this ?
awk '/Column_name/,/(^ *$|ENDOFMESSAGE)/{print}' tab.txt

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top