Forum Discussion
Jessed12345
Dec 28, 2009Employee
A slight improvement:
awk '/^virtual/,/^}$/' /config/bigip.conf
...now it will only match if 'virtual' appears at the start of the line and end when a '}' appears on a line by itself. I've tested this line with virtuals, pools, moderately complex irules, self-ips, and vlans (using the appropriate keyword in place of 'virtual', obviously). Basically every object that sprang to mind in 30 seconds. Every object was printed correctly, though I suppose it's possible that some portions of the iRules may have been cut off without my noticing.
I also find it a bit easier to use one of these, both of which will let you match on local networking objects (vlans, self-ips) as will as virtuals, pools, etc...:
awk '/^self/,/^}$/' /config/bigip.conf /config/bigip_base.conf
cat /config/{bigip.conf,bigip_base.conf} | awk '/^virtual/,/^}$/'
The creative use of awk variables or bash expansion should allow you to load a bash function that lets you use a simplified syntax, like "list virtual". I have some bash functions to handle exactly that, though they are embarassingly less elegant than this one-liner.
Hope this helps.
--jesse