Forum Discussion
don_23889
Nimbostratus
Dec 28, 2009grep'ng for 'string' in bigip.conf
grep'ng for 'string' and returning entire block of object definitions from bigip.conf for each instance of 'string', starting with 'virtual' and ending with '}'
config less bigip.con...
Jessed12345
Employee
Dec 28, 2009A 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
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects
