Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. And see here for current known issues.

New Member

show int status | options

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

Everyone's tags (5)
1 ACCEPTED SOLUTION

Accepted Solutions

Re: show int status | options

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

14 REPLIES

show int status | options

show interfaces staus | inc connected    4

Let me know if this works.

Nandan Mathure

New Member

show int status | options

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

Re: show int status | options

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

show int status | options

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



Silver

show int status | options

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

show int status | options

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

show int status | options

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.

New Member

show int status | options

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

If | represents the logical OR

what represents the logical AND?

Thanks,

Paul

Re: show int status | options

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

show int status | options

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 ***
New Member

Re: show int status | options

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

Re: show int status | options

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

show int status | options

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 ***
New Member

Re: show int status | options

Paul,

Do "sh int status | i connected 4"

When you do, copy n paste the "connected 4" part from current show int status output. You have to be sure it's looking for the correct amount of tabs or spaces.

Also, as an alternate, try "sh int status | conn.*4 "

Hth,

Dan

Sent from Cisco Technical Support iPhone App

9304
Views
10
Helpful
14
Replies
CreatePlease login to create content