Junos OS

last person joined: 5 days ago 

Ask questions and share experiences about Junos OS.
  • 1.  Cli Regex

    Posted 08-08-2014 03:59

     

    Hello,


    I want to match instances of a string of IP addresses EXACTLY in the cli.

     


    Example:

     

    1.1.1.1 or 1.1.1.2 (but nothing else e.g. 1.1.1.10 or 1.1.1.23)

     

     

    Any ideas?



  • 2.  RE: Cli Regex

     
    Posted 08-08-2014 06:05

    I guess it depends on your needs...  one thing that might work is to look for a character anything but a number at the end?

     

    root# show | match "1.1.1.1"
                address 1.1.1.1/32;
                address 1.1.1.11/32;

     

     

    root# show | match "1.1.1.1[^0-9]"
                address 1.1.1.1/32;

     

     

    The '^' means any character except the one inside the brackets...

     

     

    hoping others will chime in.

     

     

    Regards,

    Sam



  • 3.  RE: Cli Regex

    Posted 08-08-2014 06:22
    Hi, It has to be more like: show conf | display set | grep "(1.1.1.1|1.1.1.2)" This doesn't match the strings exactly. So it should be closer to: grep 1.1.1.1$|1.1.1.2$ But I don't know regex well enough...


  • 4.  RE: Cli Regex
    Best Answer

     
    Posted 08-08-2014 06:35

    It seems to work...

     

    root# show | match "1.1.1.1|1.1.1.2"
                address 1.1.1.1/32;
                address 1.1.1.11/32;
                address 1.1.1.2/32;
                address 1.1.1.22/32;

     

     

    root# show | match "1.1.1.1[^0-9]|1.1.1.2[^0-9]"
                address 1.1.1.1/32;
                address 1.1.1.2/32;

     

     

    I'm using SRX210, 12.1X44-D35.

     

    Regards,

    Sam



  • 5.  RE: Cli Regex

    Posted 08-08-2014 07:00
    Yup, that seems to work for my purposes.

    Thanks.