09-08-2011 10:12 AM - edited 03-07-2019 02:06 AM
Hi,
I would use show pipe command to get some detailed output like show interface status | inculde text1 AND text2
For example,
"show interface status" include vlan "103" and "connected".
I tried multiple combination, it looks multi pipe only give you OR output but AND output.
Thanks in advance
Solved! Go to Solution.
09-08-2011 10:34 AM
Peng
You are right in that the pipe command does not support the AND operator. You can do multiple OR commands eg.
sh int status | include Vlan | connected
but the above would show any interfaces that began with Vlan and also any connected interfaces whether or not they were vlan interfaces.
You cannot do an AND ie. show me all vlan interfaces that are also connected
note the above is a bad example because all vlan interfaces on a L3 switch should show as connected but you get the meaning.
I asked a while back on these forums whether there were any plans to add the AND operator and was told there weren't and that probably there wouldn't be in future because IOS now supports TCL and this has a much more extensive regex engine which you can use.
Jon
09-08-2011 11:04 AM
Hi Peng,
You can use "sh int status | inc connected.*103" or "sh int status | inc 103.*connected",depending on whether connexted apperas first or 103...I think connected appears first.
Paste the output of full command if it doesn't get the required output..We will refine the regex.
-Ankur
09-08-2011 10:34 AM
Peng
You are right in that the pipe command does not support the AND operator. You can do multiple OR commands eg.
sh int status | include Vlan | connected
but the above would show any interfaces that began with Vlan and also any connected interfaces whether or not they were vlan interfaces.
You cannot do an AND ie. show me all vlan interfaces that are also connected
note the above is a bad example because all vlan interfaces on a L3 switch should show as connected but you get the meaning.
I asked a while back on these forums whether there were any plans to add the AND operator and was told there weren't and that probably there wouldn't be in future because IOS now supports TCL and this has a much more extensive regex engine which you can use.
Jon
09-08-2011 10:54 AM
I am not sure but somebody told me that we can use regular expressions also after pipe ?
09-08-2011 10:59 AM
I just tried...It works
3-mem-stack#sh ip int br | inc Port.*up
Port-channel2 unassigned YES unset up up
3-mem-stack#
11-30-2016 07:23 PM
This was very helpful. I know use the following command a lot:
Switch#sho
Thank you for this extremely helpful information.
09-08-2011 11:04 AM
Hi Peng,
You can use "sh int status | inc connected.*103" or "sh int status | inc 103.*connected",depending on whether connexted apperas first or 103...I think connected appears first.
Paste the output of full command if it doesn't get the required output..We will refine the regex.
-Ankur
09-08-2011 11:41 AM
Thanks Ankur and Jon,
You guys are QUICK, yes Regrex did the trick. THANK YOU..
01-core-A-103-20#sh int status | inc connected.*103
Gi11/15 Primary Nic SSHMDF connected 103 a-full a-1000 10/100/1000BaseT
Gi11/27 reserved for NSP D connected 103 a-full a-1000 10/100/1000BaseT
Gi11/32 SSHRSS0BU301 Red H connected 103 a-full a-100 10/100/1000BaseT
Gi11/33 SSHUAA0B0001 Red H connected 103 a-full a-100 10/100/1000BaseT
Gi11/35 Core SQL Server Ge connected 103 a-full a-1000 10/100/1000BaseT
Gi12/2 Core SQL Server Ge connected 103 full 1000 10/100/1000BaseT
Gi12/14 NetIQ Security Man connected 103 full 1000 10/100/1000BaseT
Gi12/15 DC1 Root Server connected 103 a-full a-1000 10/100/1000BaseT
01-core-A-103-20#
01-core-A-103-20#sh int status | inc 103.*connected
Gi12/16 01-CA-103-24 G1/0/ connected trunk a-full a-1000 10/100/1000BaseT
11-22-2016 05:03 PM
Good one Ankur!
01-08-2019 02:38 AM
Sure you can.
Try something like this:
show vl br | include (111|222)
Best regards!
01-08-2019 04:04 AM
Just to add to the helpful commands that have been posted.
sho interfaces status | count connected
Number of lines which match regexp = 153
sho interfaces status | count notconnect
Number of lines which match regexp = 92
sho interfaces status | count connected|notconnect
Result of both.
01-23-2019 09:22 AM
Felipe,
What device and version of code are you running?
Kind Regards,
Ryan
01-23-2019 09:38 AM
Hi Ryan,
I have tried it on the following devices with the following IOS versions.
WS-C3850-48P - Version 16.3.5b
WS-C4510R+E - Version 03.09.02.E
WS-C3750X-48 - Version 15.0(2)SE, RELEASE SOFTWARE (fc1)
WS-C2960G-8TC-L - Version 12.2(58)SE1, RELEASE SOFTWARE (fc1)
FA
04-17-2023 04:33 PM
I think I may have found an "and" option. It seems like you will get different output depending on how the command is constructed.
For example. I did the following
sh start | i priv|cable - This shows me all lines that match prive OR cable
However if I enter
sh start | i priv| cable - I get the result of pirv AND cable
privilege exec level 3 test cable-diagnostics tdr interface
privilege exec level 3 test cable-diagnostics tdr
privilege exec level 3 test cable-diagnostics
privilege exec level 3 show cable-diagnostics tdr interface
privilege exec level 3 show cable-diagnostics tdr
privilege exec level 3 show cable-diagnostics
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide