cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
52220
Views
28
Helpful
15
Replies

show int status | options

paulkilcoyne
Level 1
Level 1

Hi guys,

is there a way to filter out interfaces that are in vlan 4 and are in a connected state usinf the pipe optio or is there another way?

switch01#show interfaces status

Port      Name               Status       Vlan       Duplex  Speed Type

Fa1/0/1                      notconnect   3            auto   auto 10/100BaseTX

Fa1/0/2                      notconnect   4            auto   auto 10/100BaseTX

Fa1/0/3                      notconnect   3            auto   auto 10/100BaseTX

Fa1/0/4                      notconnect   4            auto   auto 10/100BaseTX

Fa1/0/5                      notconnect   3            auto   auto 10/100BaseTX

Fa1/0/6                      notconnect   4            auto   auto 10/100BaseTX

Fa1/0/7                      notconnect   3            auto   auto 10/100BaseTX

Fa1/0/8                      notconnect   4            auto   auto 10/100BaseTX

Fa1/0/9                      notconnect   3            auto   auto 10/100BaseTX

Fa1/0/10                     connected    4          a-full  a-100 10/100BaseTX

Fa1/0/11                     connected    3          a-full  a-100 10/100BaseTX

Fa1/0/12                     notconnect   4            auto   auto 10/100BaseTX

Fa1/0/13                     connected    3          a-full  a-100 10/100BaseTX

Fa1/0/14                     connected    4          a-full  a-100 10/100BaseTX

Fa1/0/15                     notconnect   3            auto   auto 10/100BaseTX

Fa1/0/16                      notconnect   3            auto   auto 10/100BaseTX

Fa1/0/17                     connected    3          a-full  a-100 10/100BaseTX

Fa1/0/18                     notconnect   4            auto   auto 10/100BaseTX

Fa1/0/19                     connected    3          a-full  a-100 10/100BaseTX

Fa1/0/20                     notconnect   4            auto   auto 10/100BaseTX

Fa1/0/21                     notconnect   3            auto   auto 10/100BaseTX

Fa1/0/22                     notconnect   4            auto   auto 10/100BaseTX

Fa1/0/23                     notconnect   3            auto   auto 10/100BaseTX

Fa1/0/24                     connected    4          a-full  a-100 10/100BaseTX

Fa1/0/25                     notconnect   3            auto   auto 10/100BaseTX

Fa1/0/26                     connected    4          a-full  a-100 10/100BaseTX

Fa1/0/27                     notconnect   7            auto   auto 10/100BaseTX

Fa1/0/28                     connected    4          a-full  a-100 10/100BaseTX

Fa1/0/29                     connected    3          a-full  a-100 10/100BaseTX

Fa1/0/30                     connected    4          a-full  a-100 10/100BaseTX

Fa1/0/31                     notconnect   3            auto   auto 10/100BaseTX

Fa1/0/32                     connected    4          a-full  a-100 10/100BaseTX

Fa1/0/33                     notconnect   3            auto   auto 10/100BaseTX

Fa1/0/34                     notconnect   4            auto   auto 10/100BaseTX

Fa1/0/35                     connected    3          a-full  a-100 10/100BaseTX

Fa1/0/36                     notconnect   4            auto   auto 10/100BaseTX

........................................................................................................

The stack goes on quite a bit further.

Thanks,

Paul

1 Accepted Solution

Accepted Solutions

Hi Paul,

In order to match AND you can use .*

Like in your example , you wanted conected AND 4 on each line this means connected.*4, the only issue here is that this match also "notconnected 4" "notconnected 41" "connected 40" so you need also to match the space in front of connected and before and after 4.

So your match will be :

_connected.*_4_

Dan

View solution in original post

15 Replies 15

Nandan Mathure
Level 1
Level 1

show interfaces staus | inc connected    4

Let me know if this works.

Nandan Mathure

Hi Nandan,

it didn't work it just gave me a blank output. I then tried the following:

Switch01#sh int status | inc connected | inc 4

Fa1/0/10                     connected    4          a-full  a-100 10/100BaseTX

Fa1/0/11                     connected    3          a-full  a-100 10/100BaseTX

Fa1/0/13                     connected    3          a-full  a-100 10/100BaseTX

Fa1/0/14                     connected    4          a-full  a-100 10/100BaseTX

Fa1/0/17                     connected    3          a-full  a-100 10/100BaseTX

Fa1/0/19                     connected    3          a-full  a-100 10/100BaseTX

Fa1/0/24                     connected    4          a-full  a-100 10/100BaseTX

Fa1/0/26                     connected    4          a-full  a-100 10/100BaseTX

Fa1/0/28                     connected    4          a-full  a-100 10/100BaseTX

Fa1/0/29                     connected    3          a-full  a-100 10/100BaseTX

Fa1/0/30                     connected    4          a-full  a-100 10/100BaseTX

Fa1/0/32                     connected    4          a-full  a-100 10/100BaseTX

Fa1/0/35                     connected    3          a-full  a-100 10/100BaseTX

Fa1/0/40                     connected    4          a-full  a-100 10/100BaseTX

Fa1/0/48                      connected    1          a-half  a-100 10/100BaseTX

Fa2/0/19                     connected    3          a-full  a-100 10/100BaseTX

Fa2/0/20                     connected    4          a-full  a-100 10/100BaseTX

Fa2/0/21                     connected    3          a-full  a-100 10/100BaseTX

Fa2/0/42                     connected    4          a-full  a-100 10/100BaseTX

Fa2/0/45                     connected    7          a-full  a-100 10/100BaseTX

Gi2/0/1                      connected    trunk      a-full a-1000 1000BaseSX SFP

Fa3/0/15                     connected    3          a-full  a-100 10/100BaseTX

Fa3/0/19                     connected    3          a-full  a-100 10/100BaseTX

Fa3/0/21                     connected    3          a-full  a-100 10/100BaseTX

Fa3/0/24                     connected    4          a-full  a-100 10/100BaseTX

Fa3/0/26                     connected    4          a-full  a-100 10/100BaseTX

Fa3/0/35                     connected    3          a-full  a-100 10/100BaseTX

Fa3/0/40                     connected    4          a-full  a-100 10/100BaseTX

Fa3/0/42                     connected    4          a-full  a-100 10/100BaseTX

Fa4/0/9                      connected    3          a-full  a-100 10/100BaseTX

Fa4/0/11                     connected    3          a-full  a-100 10/100BaseTX

Fa4/0/21                     connected    3          a-full  a-100 10/100BaseTX

Fa4/0/22                     connected    4          a-full  a-100 10/100BaseTX

Fa4/0/27                     connected    3          a-full  a-100 10/100BaseTX

Fa4/0/31                     connected    3          a-full  a-100 10/100BaseTX

Fa4/0/32                     connected    4          a-full  a-100 10/100BaseTX

Fa4/0/35                     connected    3          a-full  a-100 10/100BaseTX

Fa4/0/44                     connected    4          a-full  a-100 10/100BaseTX

Fa4/0/46                     connected    7          a-full  a-100 10/100BaseTX

But as you can see it doesn't filter the vlan column it just includes any line with the character 4 in it.

Good effort though thanks,

Paul

Hi paul,

Please copy "connected" and "4" along with the spaces i.e copy them together from the switch output.

so it looks

"show interfaces staus | inc connected    4"

"connected    4 " ==> paste line from the actual output.

Actually this should work. Let me know.

Nandan Mathure

Hi Paul,

You might try :

show int status | i _connected.*_4_

If you want to include also the ports that are not UP

show int status | i connected.*_4_

Dan



fb_webuser
Level 6
Level 6

Try this: this is a hidden command

show interfaces staus | inc connected|4

Note that there is no space in between connected, pipe, and 4

---

Posted by WebUser Neeraj Jagga from Cisco Support Community App

Neeraj , | ( pipe ) it's not a hidden command, it represents logical OR. So include command it will match all the output that contains connected OR 4.

Dan

That is a regular expression and its not hidden command.

That would match 4 or connected so output will include uneeded stuff as well.

Fa4/0/35                     connected    3          a-full  a-100 10/100BaseTX

Fa4/0/44                     connected    4          a-full  a-100 10/100BaseTX

Fa4/0/46                     connected    7          a-full  a-100 10/100BaseTX

Dan's sol will work , even my sol will work if pasted correctly.

So it looks like there is no way to do this then?

If | represents the logical OR

what represents the logical AND?

Thanks,

Paul

Hi Paul,

In order to match AND you can use .*

Like in your example , you wanted conected AND 4 on each line this means connected.*4, the only issue here is that this match also "notconnected 4" "notconnected 41" "connected 40" so you need also to match the space in front of connected and before and after 4.

So your match will be :

_connected.*_4_

Dan

Dan,

That's awesome...I had to test it, but it does work like an AND:

R3#sh ip int brie | inc NVRAM|up

FastEthernet0/0            10.12.13.13     YES NVRAM  administratively down down   

FastEthernet0/1            10.134.0.13     YES NVRAM  up                    up     

R3#sh ip int brie | inc NVRAM.*up

FastEthernet0/1            10.134.0.13     YES NVRAM  up                    up    

RATED

HTH, John *** Please rate all useful posts ***

Dan,

I got it to work

Switch#sh int status | inc connected.*    4

Fa1/0/3                      connected    4          a-full  a-100 10/100BaseTX

Fa1/0/5                      connected    4          a-full  a-100 10/100BaseTX

Fa1/0/9                      connected    4          a-full  a-100 10/100BaseTX

Fa1/0/11                     connected    4          a-full  a-100 10/100BaseTX

Fa1/0/13                     connected    4          a-full   a-10 10/100BaseTX

Fa1/0/20                     connected    4          a-full  a-100 10/100BaseTX

Fa1/0/22                     connected    4          a-full  a-100 10/100BaseTX

Fa1/0/24                     connected    4          a-full  a-100 10/100BaseTX

Fa1/0/28                     connected    4          a-full  a-100 10/100BaseTX

Fa1/0/32                     connected    4          a-full  a-100 10/100BaseTX

Fa1/0/35                     connected    4          a-full  a-100 10/100BaseTX

Fa1/0/36                     connected    4          a-full  a-100 10/100BaseTX

Fa1/0/38                     connected    4          a-full  a-100 10/100BaseTX

Fa1/0/42                     connected    4          a-full  a-100 10/100BaseTX

Fa2/0/6                      connected    4          a-full  a-100 10/100BaseTX

Fa2/0/7                      connected    4          a-full  a-100 10/100BaseTX

Fa2/0/9                      connected    4          a-full  a-100 10/100BaseTX

Fa2/0/11                     connected    4          a-full  a-100 10/100BaseTX

Fa2/0/16                     connected    4          a-full  a-100 10/100BaseTX

Fa2/0/24                     connected    4          a-full  a-100 10/100BaseTX

Fa2/0/26                     connected    4          a-full  a-100 10/100BaseTX

Fa2/0/28                     connected    4          a-full  a-100 10/100BaseTX

Fa2/0/29                     connected    4          a-full  a-100 10/100BaseTX

Fa2/0/32                     connected    4          a-full  a-100 10/100BaseTX

Fa2/0/33                     connected    4          a-full  a-100 10/100BaseTX

Fa2/0/34                     connected    4          a-full  a-100 10/100BaseTX

Fa2/0/35                     connected    4          a-full  a-100 10/100BaseTX

Fa2/0/39                     connected    4          a-full  a-100 10/100BaseTX

Fa2/0/41                     connected    4          a-full  a-100 10/100BaseTX

So the space between the connected and 4 was key.

This also worked:

Switch#sh int status | inc connected    4

Thanks all for contributing,

Regards,

Paul

Paul ,

There is a character that will ease your matching work

This is "_" ( underscore ) = that , in this case , will help you match space. Why do you need to match space ? Because you have it in front of connected and 4 and after 4.

Example :

Fa2/0/28                     connected    4          a-full  a-100 10/100BaseTX

You need to match all the interfaces on switch 2 & connected  & half-duplex

show int status | i Fa2.*_connected.*half

Why I am telling you this , because in you solution - even though you matched want you need - you could use the underscore before and after 4 with out any space

sh int status | i connected.*_4_

Dan

thanks, i am working for a while on the cisco switches and i didnt know this

Paul,

There's not a logical && per se. Like others posted, when you use the pipe in succession in the same line it acts as an AND.

sh int | inc bia|rx|output

Or

R3#sh run | inc FastEther|router|line

interface FastEthernet0/0

interface FastEthernet0/1

router ospf 1

passive-interface FastEthernet0/0

line con 0

line aux 0

line vty 0 4

HTH, John *** Please rate all useful posts ***
Review Cisco Networking for a $25 gift card