Support Support Downloads Knowledge Base Case Manager My Juniper Community

Knowledge Base

Search our Knowledge Base sites to find answers to your questions.

Ask All Knowledge Base Sites All Knowledge Base Sites JunosE Defect (KA)Knowledge BaseSecurity AdvisoriesTechnical BulletinsTechnotes Sign in to display secure content and recently viewed articles

[Junos] Match condition on Junos CLI for very specific interface data

0

0

Article ID: KB35872 KB Last Updated: 09 Jun 2020Version: 1.0
Summary:

The article explains how to effectively use the match condition on Junos OS Command Line Interface while matching a large data set that has very few strings in common. The article explains the match conditions on a set of interfaces on different Flexible PIC Concentrators (FPCs) and Physical Interface Cards (PICs).

 

Solution:

The "|" operator indicates that a match can be one of the two terms on either side of the pipe ( | ). 

The "[ ]" operator specifies a range of letters or digits to match. To separate the start and end of a range, you would use a hyphen ( - ). However, you may also use "," within the "[ ]" to separate each letter or alphabet that is to be matched.

Suppose that a user wants to fetch data related to a set of interfaces that are listed on the device and that exist on different FPCs and PICs.

Let's consider the list of interfaces to be:

xe-0/0/8, ge-0/0/18, xe-0/0/26, xe-0/0/44, xe-1/0/15, xe-2/0/10, xe-2/0/11, xe-2/0/12, xe-3/0/15, xe-3/0/22, xe-3/0/25, and xe-3/0/28

The match condition should look like the following:

user@host>show configuration interfaces | display set | match xe-0/0/[8,26,44]|ge-0/0/18|xe-1/0/15|xe-2/0/[10,11,12]|xe-3/0/[15,22,25,28]

From shell prompt:

user@host> start shell
% cli -c "show configuration interfaces | display set" | egrep "xe-0/0/[8,26,44] | ge-0/0/18 | xe-1/0/15 | xe-2/0/[10,11,12] | xe-3/0/[15,22,25,28]

Note: Be aware that the above match condition will also display the configuration of all interfaces that match the given string.

That is: When you match xe-0/0/[1,2,3], you are expecting outputs xe-0/0/1, xe-0/0/2, and xe-0/0/3. But the outputs will include details of interfaces starting with xe-0/0/1, xe-0/0/2, and xe-0/0/3, along with xe-0/0/11, xe-0/0/12, xe-0/0/21, xe-0/0/22, xe-0/0/31, xe-0/0/32, and so on.

To make your search more specific (and prevent running into the above problem), you can add the allowed variables list for each digit.

Example

user@host> show configuration interfaces |display set | match "et-0/0/[1-3][1-4] " 

The match condition in the above command checks for an interface that has its port number starting with 1,2,3 and ending with 1,2,3,4. The output will have the configuration of interfaces: et-0/0/11, et-0/0/12, et-0/0/13, et-0/0/14, et-0/0/21, et-0/0/22, et-0/0/23, et-0/0/24, et-0/0/31, et-0/0/32, et-0/0/33, et-0/0/34.

This condition prevents the display of unwanted data and only gives information about the interfaces mentioned in the above list.

 

Related Links

Comment on this article > Affected Products Browse the Knowledge Base for more articles related to these product categories. Select a category to begin.

Getting Up and Running with Junos

Getting Up and Running with Junos Security Alerts and Vulnerabilities Product Alerts and Software Release Notices Problem Report (PR) Search Tool EOL Notices and Bulletins JTAC User Guide Customer Care User Guide Pathfinder SRX High Availability Configurator SRX VPN Configurator Training Courses and Videos End User Licence Agreement Global Search