Forum Discussion

don_23889's avatar
don_23889
Icon for Nimbostratus rankNimbostratus
Dec 28, 2009

grep'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.conf |grep -B5 -A5 string |more 

 

This is cumbersome since you have to guess for -B(x) and -A(x)

 

 

So, as an example, I want to return all object definitions with iRule 'http-xff'. Basically, all lines between [virtual] and [}]

 

 

This example is syntactically incorrect, and only for illustrating what I am trying to achieve....ie...pseudo-code.

 

 

 
  less bigip.conf |grep BEGIN[virtual] END[}] http-xff |more 
  
 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 
 } 
  
 

 

 

What would really be sweet, would be to grep for a given 'string', and return entire block for 'any' object definition...where the preceding line and following line are are both blank. This would return all object definitions for a given string...virtual, pool, monitor...etc.

30 Replies