fork download
  1. #!/bin/bash
  2. awk '/^edit / {
  3. rec = 1
  4. s = $0
  5. next
  6. }
  7. rec {
  8. s = s ORS $0
  9. }
  10. /^next/ {
  11. if (s ~ /set associated-interface "interface1"/)
  12. print s
  13. rec = 0
  14. }'
  15.  
Success #stdin #stdout 0.01s 5304KB
stdin
edit "ip_address_1"
    set uuid 8b6d9bd0-9fe7-51ee-d54d-d904bfc9a7e1
    set associated-interface "interface1"
    set subnet 10.0.0.1 255.255.255.255
next
edit "ip_address_2"
    set uuid a3465e68-9fe7-51ee-cf95-96b35ab0532e
    set associated-interface "interface1"
    set subnet 10.0.0.2 255.255.255.255
next
edit "ip_address_3"
    set uuid c1b62e20-9fef-51ee-5915-14502d40552e
    set associated-interface "interface2"
    set subnet 10.0.0.3 255.255.255.255
next
stdout
edit "ip_address_1"
    set uuid 8b6d9bd0-9fe7-51ee-d54d-d904bfc9a7e1
    set associated-interface "interface1"
    set subnet 10.0.0.1 255.255.255.255
next
edit "ip_address_2"
    set uuid a3465e68-9fe7-51ee-cf95-96b35ab0532e
    set associated-interface "interface1"
    set subnet 10.0.0.2 255.255.255.255
next