Rate and give feedback:
Feedback Received. Thank You!
Example: Using Global Replace in a Junos Configuration—Using
the upto Option
Consider the hierarchy shown in Figure 1. The text string 010101 appears in three places: the description
sections of ge-0/0/0, ge-0/0/0.0, and fe-0/0/1. These three instances are three objects. The following example
shows how you can use the upto option to perform replacements
in a JUNOS configuration:
Figure 1: Replacement by Object
An upto 2 option in the replace command converts 01 to 02 for two object instances. The objects under the main
interfaces ge-0/0/0 and fe-0/0/1 will be replaced
first (since these are siblings in the hierarchy level). Because of
the upto 2 restriction, the replace command replaces
patterns in the first and second instance in the hierarchy (siblings),
but not the third instance (child of the first instance).
user@host# show interfacesge-0/0/0 {description "mkt 010101"; #First instance in the hierarchyunit 0 {description "mkt 010101"; #Third instance in the hierarchy (child of the firstinstance)}}fe-0/0/1 {description "mkt 010101"; #second instance in the hierarchy (sibling of the firstinstance)unit 0 {family inet {address 200.200.20.2/24;}}}[edit]user@host# replace pattern 01 with 02 upto 2[edit]user@host# commitcommit complete
[edit]user@host# show interfacesge-0/0/0 {description "mkt 020202"; #First instance in the hierarchyunit 0 {description "mkt 010101"; #Third instance in the hierarchy (child of the firstinstance)}}fe-0/0/1 {description "mkt 020202"; #second instance in the hierarchy (sibling of the firstinstance)unit 0 {family inet {address 200.200.20.2/24;}}}
Published: 2012-11-27