Most of you will be aware that you can use regular expressions to transform/filter the output of any command in JUNOS with a show blah | match “ge-*/0/[0-9]”, the one catch with this method is that it kills the headers for each column of output.
There’s actually another way to achieve this, which is to write the regexp directly into the show command. You can actually do this with most show commands in JUNOS (though the example below is a show interfaces, i’ve also tried this on ISIS, RSVP and OSPF output). The advantage of this way is that it preserves any information that is not related to a specific interface, making the command clearer to read.
To do this, just write any interface-specific command and put the regexp at the end. For example show rsvp interfaces ae* will show you all the RSVP AE interfaces. Or the below output will show you only the gigabit interfaces that match ge-*/0/* (i.e. over two line cards, but one set of interfaces within the line card);
[email protected]> show interfaces terse ge-*/0/* Interface Admin Link Proto Local Remote ge-0/0/0 up down ge-0/0/1 up down ge-0/0/2 up down ge-0/0/3 up down ge-0/0/4 up down ge-0/0/5 up down ge-0/0/6 up down ge-0/0/7 up down ge-0/0/8 up down ge-0/0/9 up down ge-2/0/0 up up ge-2/0/1 up up ge-2/0/2 up up ge-2/0/3 up up ge-2/0/4 up up ge-2/0/5 up down ge-2/0/6 up up ge-2/0/7 up up ge-2/0/8 up down ge-2/0/9 up up
I’ve explained this to a few people this week, so figured it would be a good thing to post here in case anyone hasn’t already picked this up.
Hope this helps!