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

get lines with an if clause

Status
Not open for further replies.

ozi403

Technical User
Apr 29, 2002
54
0
0
TR
name: ata
group: atagroup;
save set: /ger
/germe
storage nodes: ata2
cl OS type: yyy

name: ozan
group: ;
save set: /etc
storage nodes: ozi
cl OS type: xxx

I try to get lines between "save set:" and "storage nodes:"
if "group:" value is ";" . Then I wrote this:

awk '$1=="group:"{if($2~/;/)}{/save set:/,/storage nodes:/}'

but it prints every lines without if clause.

Thanks for helps.
 
Hi

If I understand correctly...
Code:
awk '$1=="group:"{v=$2!=";"}/save set:/,/storage nodes:/{if(v)print}' /input/file
If not, please rephrase the requirements.

Tested with [tt]gawk[/tt].

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top