cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
31771
Views
6
Helpful
1
Replies

How to use output modifiers - pipe symbol

kevin.hu
Level 3
Level 3

Hi,

 

I figure out how to use the pipe symbol to form "AND" operator, such as

show cdp nei

| ex Gig|VMware (exclude BOTH Gig AND VMware keywords).

 

However, does anyone know how to use the pipe or other symbol to form "OR" and "NOT" operators?

 

Thanks.

1 Accepted Solution

Accepted Solutions

slmansfield
Level 4
Level 4

The output of CLI commands can be modified using regular expressions.  Here is a URL that describes how to use them.  http://www.cisco.com/en/US/docs/ios/12_0t/12_0t1/feature/guide/cliparse.html#wp6028

I took the output of

show ip interface brief

which listed a bunch of different interfaces on my 2800 router, including Loopback0 and Tunnel0 interfaces.

To test the "or" I used another pipe between the two terms that I want to "or", which in this case is Loopback or Tunnel.  After the "or" I only want to see the Tunnel interface, so I just include that from the output of the prior selection for Loopback or Tunnel.

router#sh ip int brief | include Loopback|Tunnel | include Tunnel
Tunnel0                    1.1.1.1     YES NVRAM  administratively down down

To use a "NOT" condition I just use the "exclude" after whatever selection I chose prior to the exclude.  In this case, I first chose Loopback or Tunnel.  From that output I excluded Tunnel so that I only have Loopback in my output.

router#sh ip int brief | include Loopback|Tunnel | exclude Tunnel
Loopback0                  2.2.2.2   YES NVRAM  up                    up

HTH

View solution in original post

1 Reply 1

slmansfield
Level 4
Level 4

The output of CLI commands can be modified using regular expressions.  Here is a URL that describes how to use them.  http://www.cisco.com/en/US/docs/ios/12_0t/12_0t1/feature/guide/cliparse.html#wp6028

I took the output of

show ip interface brief

which listed a bunch of different interfaces on my 2800 router, including Loopback0 and Tunnel0 interfaces.

To test the "or" I used another pipe between the two terms that I want to "or", which in this case is Loopback or Tunnel.  After the "or" I only want to see the Tunnel interface, so I just include that from the output of the prior selection for Loopback or Tunnel.

router#sh ip int brief | include Loopback|Tunnel | include Tunnel
Tunnel0                    1.1.1.1     YES NVRAM  administratively down down

To use a "NOT" condition I just use the "exclude" after whatever selection I chose prior to the exclude.  In this case, I first chose Loopback or Tunnel.  From that output I excluded Tunnel so that I only have Loopback in my output.

router#sh ip int brief | include Loopback|Tunnel | exclude Tunnel
Loopback0                  2.2.2.2   YES NVRAM  up                    up

HTH