Using this:
awk '$1 == "pool" { f=1; print $1,$2; next }
f == 1 { if ($1 == "pool") { print }
else if ($1 == "members") { print }
else if ($0 ~ /^}/) { f=0 }
}' bigip.conf
That works fine until the config has the IPs on following lines.
How can I get it to print the IPs if they are on following lines.
The config has both, some have it on the same line, some on then next 1, 2 or 3 lines.
the data :
pool pl_stage_xxx_microsites_9483 {
monitor all tcp_half_open
members {
11.11.11.11:9483 {}
11.22.22.22:9483 {
session user disabled
}
}
}
It’s hard to say without seeing more of your data and your expected output but I think all you need is something like this:
The above should be a good starting point at least. wrt the other answer posted using getline – getline has some appropriate uses but this isn’t one of them, don’t use getline until you fully understand and can live with all of it’s caveats, see http://awk.info/?tip/getline.