11-17-2009
08:23 AM
- last edited on
06-15-2023
11:33 AM
by
Translator
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.
Solved! Go to Solution.
11-20-2009
06:16 AM
- last edited on
06-15-2023
11:37 AM
by
Translator
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
11-20-2009
06:16 AM
- last edited on
06-15-2023
11:37 AM
by
Translator
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
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