Junos OS

last person joined: 2 days ago 

Ask questions and share experiences about Junos OS.
  • 1.  Using Wildcards with Configuration Groups - especially question mark

    Posted 10-10-2011 02:06

    Hi there,

     

    Does anyone have some good examples on how to use wildcards in apply-groups?

     

    http://www.juniper.net/techpubs/en_US/junos11.2/topics/concept/junos-cli-wildcard-characters-configuration-groups-usage.html

     

    Here, we have the documentation for wilcard matching..., question marks, character classes, etc.

     

    However, first of all, I can not type the question mark, since it brings up the "help" command completion... Here are a couple of examples on what I would like to type, but cannot:

     

    <3[023]??>

    <3[023][0-9][0-9]>

     

    Does anyone know how to type the question mark, or how to write several character classes?

     

    Thanks.



  • 2.  RE: Using Wildcards with Configuration Groups - especially question mark

    Posted 10-10-2011 05:22

    > Does anyone know how to type the question mark, or how to write several character classes?

     

    Hi PerG,

     

    Just enclose your regular expression within double quotes, like this:

     

    "<ge-[0-3]/?/*>"

     

    ..that should do the trick.

     

    Saverio



  • 3.  RE: Using Wildcards with Configuration Groups - especially question mark

    Posted 10-10-2011 06:29

    Hi,

     

    I am actually working unit numbers, and not interface names, although that is not very relevant.

     

    First, it was clearly the double quotes and the / escape character I was missing - to be able to type a question mark at all. However, even with that, I can not get the question mark to catch:

     

    if I want to match 3303, 

     

    "<3*03>"will work

    "<3/?/03>"does not work

    "<3/?03>"does not work

     

    Any idea?

    Any documentation?



  • 4.  RE: Using Wildcards with Configuration Groups - especially question mark

    Posted 10-10-2011 06:31

    Neither does this:

     

     "<3[023]/?/*>"



  • 5.  RE: Using Wildcards with Configuration Groups - especially question mark

     
    Posted 10-18-2011 13:34
    Hi PerG,

    please show us your group config and configuration fragment you want to match. Matching just unit number or full interface name ?

    "<3[023]/?/*>" may be a part of interface name. It won't match any interface name nor unit number. You need to match whole item/word.
    jtb


  • 6.  RE: Using Wildcards with Configuration Groups - especially question mark

    Posted 10-18-2011 22:35

    Hi,

     

    It is actually the full string:

     

    GROUPNAME {
    interfaces {
    <*> {
    unit "<3[023]*>" {

     

    And the idea was to match that on any interface name, for units with 4-digit unit numbers of 3x.., where x is 0, 2 or 3.

     

    This works:

    "<3[023]*>"

    but it obviously does not restrict the unit string to be 4 digits only.



  • 7.  RE: Using Wildcards with Configuration Groups - especially question mark

     
    Posted 10-19-2011 00:24

    hi PerG,

     

    "<3[023]>" will just match units 3x, where x is 0,2 or 3

    "<3[023][023][023]>" is the wildcard you need:  units with 4-digit unit numbers of 3xxx, where x is 0, 2 or 3

     

    From the documentation URL: A character class matches any of the characters between the square brackets - any single character from the class, not any string of the characters.

    jtb



  • 8.  RE: Using Wildcards with Configuration Groups - especially question mark

    Posted 10-19-2011 00:33

    Thanks for the input. However, as I mentioned in the first post I tried:

     

    <3[023][0-9][0-9]>

     

    and it did not work...



  • 9.  RE: Using Wildcards with Configuration Groups - especially question mark
    Best Answer

     
    Posted 10-19-2011 00:43

    hi,

     

    "<3[023][0-9][0-9]>" will match 3xxx, where x is 0, 2 or 3, sure. Please re-test.

     

    Just did the simple test:

     

    admin@s1# show groups u3x00 
    interfaces {
        <*> {
            unit "<3[023][0-9][0-9]>" {
                description u3x00;
            }
        }
    }
    
    [edit]
    admin@s1# show interfaces apply-groups                     
    apply-groups u3x00;
    
    [edit]
    admin@s1# show interfaces fe-0/0/4  
    vlan-tagging;
    unit 333 {
        vlan-id 333;
        family inet;
    }
    unit 3023 {
        vlan-id 3023;
        family inet;
    }
    unit 3333 {
        vlan-id 3333;
        family inet;
    }
    
    [edit]
    admin@s1# show interfaces fe-0/0/4 | display inheritance 
    vlan-tagging;
    unit 333 {
        vlan-id 333;
        family inet;
    }
    unit 3023 {
        ##
        ## 'u3x00' was inherited from group 'u3x00'
        ##
        description u3x00;
        vlan-id 3023;
        family inet;
    }
    unit 3333 {
        ##
        ## 'u3x00' was inherited from group 'u3x00'
        ##
        description u3x00;
        vlan-id 3333;
        family inet;
    }
    
    [edit]

     

    BTW in one post above you describe "/" as 'escape character'. It's not true, the "/" is regular character in wildcard context.

    jtb 



  • 10.  RE: Using Wildcards with Configuration Groups - especially question mark

    Posted 09-19-2013 18:32

    Old thread, but maybe someonewill still see this.

     

    I have a smiliar challenge.I a also trying to match a wildcard on unit numbers, but I want to match all unit numbers between 0 and 4999.  I cant figure out how to get it done in one statement.

     

    "<[0-4][0-9][0-9][0-9]>" is close, but only matches 4 didgit numbers, so it essentially matches 1000-4999

     

    Using two  stanzas as follows works, but is clunky

     

    interfaces {
        <*> {
            unit "<[1-4]*>" {
                family inet {
                    mtu 1500;
                }
            }
            unit "<[0-9]>" {
                family inet {
                    mtu 1500;
                }
            }
        }
     
    Any ideas?