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...
hwidjaja_37598
Altostratus
Dec 28, 2009Try using perl, cut and paste this code to a file (eg. /tmp/mygrep.pl) and make sure the executable bit is set (eg. chmod a+x /tmp/mygrep.pl)
!/usr/bin/perl
use strict;
my ($File, $Pattern) = @ARGV;
my $buf;
open (fh, $File) || die "Cant open $File";
{
local $/;
$buf=;
}
close (fh);
while ($buf =~ /([^\n]*\{[^\{]*$Pattern[^\}]*\})/sg){
print "$1\n---\n";
}
Sample:
[root@bigip:Active] config /tmp/mygrep.pl /config/bigip.conf http-xff
virtual vip1.80 {
pool vip1.80
destination aaa.bbb.ccc.ddd:http
ip protocol tcp
rules SNAT2VIP
profiles
http-xff
tcp-lan-optimized
serverside
tcp-wan-optimized
clientside
persist source_addr_30min
}
---
virtual vip-2.80 {
pool vip-2.80
destination mmm.nnn.ooo.ppp:http
ip protocol tcp
rules SNAT2VIP
profiles
http-xff
tcp-lan-optimized
serverside
tcp-wan-optimized
clientside
persist source_addr_30min
}
---
[root@bigip:Active] config /tmp/mygrep.pl /config/bigip.conf password
user root {
password crypt "[cut]"
}
---
user admin {
password crypt "[cut]"
description "Admin User"
group [cut]
home "[cut]"
shell "[cut]"
role administrator in all
}
---
user f5emsvr {
password crypt "[cut]"
description "F5 EM Service Account"
id [cut]
group [cut]
home "[cut]"
shell "[cut]"
role guest in all
}
---
configsync {
password crypt "[cut]"
}
---
It's not well tested, use it at your own risk and on dev machine first.
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
