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 or sed.. 1

Status
Not open for further replies.

ogniemi

Technical User
Nov 7, 2003
1,041
PL
how to get from each stanza in a file first line (of the stanza)

stanza1_line1
stanza1_line2
stanza1_line3

stanza2_line1
stanza2_line2

stanza3_line1
stanza3_line2



The mached lines should be:

stanza1_line1
stanza2_line1
stanza3_line1

 
A starting point:
awk '
NF && !nr++
!NF{nr=0}
' /path/to/input > output

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 

thx.

is it also possible to be done with sed?

I am looking for a oneliner to this task. (but of course "awk '^JNF && !nr++^J!NF{nr=0}^J'" is ok!)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top