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

Sed or Awk question

Status
Not open for further replies.

jgercken

MIS
Feb 13, 2002
304
US
What I want to do is to parse a file outputting everything between a line containing string and the next line containing just a \n. There will be a number of these sets in each file. Any thoughts?
-Jeff

bla bla bla
bla bla bla
bla bla string bla <---- start output
bla bla bla
bla bla bla
<---- stop output

bla bla bla
bla bla bla
bla string <---- start output
bla
<---- stop output


----------------------------------------
Wasabi Pop Tarts! Write Kellogs today!
 
Code:
sed -n '/string/,/^$/p'

--------------------
&quot;When all else has failed, read the manuals.&quot;

Denis
 
And the solution:
Code:
awk '/string/,!NF'

Hope This Help
PH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top