CCNA (ICND2)ManagementUseful Commands

Using the Pipe ‘|’ command

Using the Pipe ‘|’ is by far one of the most important things you can learn on a Cisco device. I never really appreciated this command when I started out in Cisco, as it seemed to take me longer to use it, and I didn’t get to see what I was looking for. In hind sight this was because I didn’t know how to use it correctly, and I was working on devices that didn’t have very large configuration files.


When I started working on larger scale enterprise networks, I became very frustrated that I could not find what I was looking for quickly. It was only then that I re-looked at this command and it made me far more efficient at my job. I often work on Cisco devices that over 3000 lines of configuration, so doing a standard ‘sh run’ just isn’t an option.


The pipe command can be used with any ‘show’ command. In the live demo below, I have demonstrated how it can be used with the ‘show run’ command. In order to use the pipe we need to first look at the syntax required for it and options it supports. The most common values for the pipe are ‘include’ ‘begin’ ‘exclude’. These enable us to use the ‘show’ command and have the device only display lines in the output that include a value, exclude a value, or display everything from the beginning of a value.


In the below demo I started by using the ‘sh run | in interface’ I have used the shortened version of the commands so the full command would have been “show running-config | include interface’ This has instructed the device to display only lines in the running-config that have the word ‘interface’


My second command is ‘sh run | in serial’ which will show me all lines in the configuration that have the word ‘serial’ in them. You will notice that I have used the same command again, but used ‘sh run | in Serial’ with a uppercase ‘S’ to illustrate that the command is case SeNsItIvE and you will notice the results are very different.


Lastly, I have demonstrated the ‘exclude’ command by issuing ‘sh run | ex interface’ to the device, and you will notice the entire running-config was displayed but every line that had the word ‘interface’ has been removed.


If you can see this, then you might need a Flash Player upgrade or you need to install Flash Player if it's missing. Get Flash Player from Adobe.

Leave a Reply

Your email address will not be published. Required fields are marked *