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

How to use output modifiers - pipe symbol

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
Silver

Re: How to use output modifiers - pipe symbol

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

1 REPLY
Silver

Re: How to use output modifiers - pipe symbol

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

19616
Views
0
Helpful
1
Replies
CreatePlease to create content