LTM script modification
Was wondering if a SED Guru could help me but looking to transform a certain lines of configs in my f5 configuration using bash. i will have another file with an ip address mapping to do modification of the configuration.
Lets say i have an ip mapping of
1.1.1.1 that will need to change to 4.4.4.4
cat test.txt
ltm pool test_pool { members { 1.1.1.1:8004 { address 1.1.1.1 session user-disabled state user-down } 2.2.2.2:8358 { address 2.2.2.2 session monitor-enabled state up } 3.3.3.3:8218 { address 3.3.3.3 session user-disabled state down } } monitor nb-http-iis_mon }
I would need to transfer the line to something like this
modify ltm pool ptest_pool add { members { 4.4.4.4:8004 { address 4.4.4.4 session user-disabled state user-down } } monitor nb-http-iis_mon }
=================================== cat test.txt | sed 's/ +/ /g;s/ltm pool/\nmodify ltm pool/g; s/pool { members {/pool add { members {/g; s/1.1.1.1/4.4.4.4/g'
result modify ltm pool test_pool add { members { 4.4.4.4:8004 { address 4.4.4.4 session user-disabled state user-down } 2.2.2.2:8358 { address 2.2.2.2 session monitor-enabled state up } 3.3.3.3:8218 { address 3.3.3.3 session user-disabled state down } } monitor nb-http-iis_mon }
Does anyone know the sed syntax to make it stop after first pattern match of state user-down|up }