Hi List,

I have a text test.txt file looks like below:

stp instance 0 {
   interfaces 1.1 {
         external path cost 20000
         internal path cost 20000
      }
   vlans {
      internal
      vlan10
   }
}
profile http http_global {
   defaults from http
   max header size 38912
   encrypt cookies {
      "F-P-SES"
   }
}
profile tcp tcp {
   reset on timeout enable
   time wait recycle enable
   delayed acks enable
   proxy mss disable
}
vlan vlan10 {
   tag 1330
   interfaces tagged 1.1
}
route domain 10 {
   parent id 0
   description "RD10"
   vlans vlan10
}
route domain 12 {
   parent id 10
   description "RD12"
   vlans vlan12
}

how can I find a specific profile { } block and remove/replace that
part from the file, for example, I want to remove below block or
replace it with emtpy blank line

profile tcp tcp {
   reset on timeout enable
   time wait recycle enable
   delayed acks enable
   proxy mss disable
}

and the { } could have nested { } block too.

I tried:

perl -e '$/=undef;foreach $profile (<>=~m/profile.*?{.*?}/gs) { print
"$profile\n"; }' < /tmp/test.txt

to search and print out the all profile, any tips/sample codes would
be very much apprecaited.

Thanks

Vincent

-- 
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/


Reply via email to