This document describes the problem encountered when a pipe symbol (|) is used in order to filter outputs and also describes the correct syntax of regular expressions used along with show commands to avoid unexpected results.
There are no specific requirements for this document.
The information in this document is based on the correct use of the pipe symbol in order to filter outputs based on strings.
The information in this document was created from the devices in a specific lab environment. All of the devices used in this document started with a cleared (default) configuration. If your network is live, make sure that you understand the potential impact of any command.
The use of the pipe symbol in the command below returns incorrect output.
Switch#show run | include 126.96.36.199
ip address 192.168.51.131 255.255.255.0
ip address 188.8.131.52 255.255.255.0
Use a dot (.) in order to match any single character, including a space and number. In the example above, 184.108.40.206 matches:
192.168.51.131 255.255.255.0 and 220.127.116.11 255.255.255.0
If you require a match with a special character, you must suppress its meaning with a backslash (\). For example:
Switch# show run | include 1.1.1\.2 does not match IPs above
This behavior follows from the definition of Regular Expressions.