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
Jan 01, 2010I have been inspired. Building off the pretty much every other poster in this thread, here's my not-exactly-a-one-liner solution:
list() {
object=$1
pattern=$2
if [ -z "$2" ]; then
awk '/'^"$object"'/,/^}$/ {print}' /config/bigip{.conf,_base.conf}
else
for i in $(b $object list | awk 'BEGIN {RS="\n}"} /'"$pattern"'/ {print $2}'); do
awk '/'^"$object $i"'/,/^}$/ {print}' /config/bigip{.conf,_base.conf}
done
fi
}
Put that at the bottom of the '/root/.bash_profile' file, then either logout and back in, or source the file with:
source /root/.bash_profile
After that you can either search for all objects of a certain type with:
list
Or you can search for the set of objects that contain a specific pattern with:
list
Your original example would work with:
list virtual http-xff
This isn't nearly as fast as Humphrey's perl script, and certainly not as fast as a good awk one-liner, but it's flexible, and it will work with patterns that are contained within an embedded block ({...}) in the object. One example would be trying to find all SSL vips that use a specific clientside profile, or all iRules that use a certain pool within an if/else, etc... I've tested it a bit, but I may have missed some condition that causes it to fail. If you catch something that I didn't, please let me know.
If your worried about losing your .bash_profile during an upgrade, you can copy this to a file and put that file in /shared/bin (the 'bin' sub-dir does not exist by default). Then add this to the bottom of your .bash_profile:
source /path/to/file
Actually, I keep all funtions like this in a file located in /shared/bin, then source that file from .bash_profile so everything is available on login. If I boot to the other partition all I need to do to get everything back is re-add the 'source' command to .bash_profile.
PS> I tried -a lot- to isolate the object name from within a single awk statement rather than resorting to calling bigpipe... it will take someone better than I to make it happen.
--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
