
Document ID: 116131
Updated: Jun 14, 2013
Contributed by Shashank Singh, Cisco TAC Engineer.
Contents
Introduction
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.
Prerequisites
Requirements
There are no specific requirements for this document.
Components Used
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.
Problem
The use of the pipe symbol in the command below returns incorrect output.
Switch#show run | include 1.1.1.2
ip address 192.168.51.131 255.255.255.0
ip address 198.1.1.1 255.255.255.0
Solution
Use a dot (.) in order to match any single character, including a space and number. In the example above, 1.1.1.2 matches:
192.168.51.131 255.255.255.0 and 198.1.1.1 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.
Related Information
Open a Support Case (Requires a Cisco Service Contract.)
Related Cisco Support Community Discussions
The Cisco Support Community is a forum for you to ask and answer questions, share suggestions, and collaborate with your peers.
Refer to Cisco Technical Tips Conventions for information on conventions used in this document.