show interface | i (line protocol|error|rate)
bunker-3825-r1#show interface | i (line protocol|error|rate)
GigabitEthernet0/0 is up, line protocol is up
Queueing strategy: fifo
5 minute input rate 4882000 bits/sec, 1425 packets/sec
5 minute output rate 909000 bits/sec, 1188 packets/sec
2 input errors, 0 CRC, 0 frame, 2 overrun, 0 ignored
0 output errors, 0 collisions, 0 interface resets
Below the basic Cisco IOS regular expression characters and their functions.
Regular Expression Character |
Function |
Examples |
. |
Matches any single character. |
|
\ |
Matches the character following the backslash. Also matches (escapes) special characters. |
|
[ ] |
Matches the characters or a range of characters separated by a hyphen, within left and right square brackets. |
|
^ |
Matches the character or null string at the beginning of an input string. |
|
? |
Matches zero or one occurrence of the pattern. (Precede the question mark with Ctrl-V sequence to prevent it from being interpreted as a help command.) |
|
$ |
Matches the character or null string at the end of an input string. |
|
* |
Matches zero or more sequences of the character preceding the asterisk. Also acts as a wildcard for matching any number of characters. |
|
+ |
Matches one or more sequences of the character preceding the plus sign. |
|
() [] |
Nest characters for matching. Separate endpoints of a range with a dash (-). |
|
| |
Concatenates constructs. Matches one of the characters or character patterns on either side of the vertical bar. |
|
_ |
Replaces a long regular expression list by matching a comma (,), left brace ({), right brace (}), the beginning of the input string, the end of the input string, or a space. |
The characters _1300_ can match any of the following strings: |
MyRTR#show run ?
brief
configuration without certificate data
class-map Show class-map
information
full
full configuration
interface Show interface
configuration
linenum Display
line numbers in output
map-class Show map class
information
policy-map Show policy-map
information
view
View options
|
Output modifiers
<cr>
The option we are interested in is the “|” (Output modifier). We can quickly see that if we include that “|” as a parameter and use our trusty old “?”, we have more options.
MyRTR#show run | ?
append Append
redirected output to URL (URLs supporting append operation
only)
begin Begin with
the line that matches
exclude Exclude lines that
match
include Include lines that
match
redirect Redirect output to
URL
section Filter a section of
output
tee
Copy output to URL
The ones I find really useful are include, begin and section. You can also play around with the exclude option as well. I’ve not seen any real world use cases for the rest (but I’m sure they exist). The simplest of these to understand is the “include” command. This command parses the output of whatever command precedes the “|” and only presents whatever matches a filter that we need to provide. For example, I could issue the command “show run | include address”. The entire output of the running-config would be piped out to the include command and filtered against “address”. So I would expect to see output similar to the following.
MyRTR#show run | inc address
ip address 1.1.1.1 255.255.255.0
ip address 2.2.2.2
255.255.255.0
ip address 10.1.1.1 255.255.255.0
I could also get fancy with the filter that I am using. I could use wildcards that are similar to regex.
//all instances of “address”
MyRTR#show run | inc address
ip address 1.1.1.1
255.255.255.0
ip address 2.2.2.2 255.255.255.0
ip address 10.1.1.1 255.255.255.0
//all instances of address with a space, a
single character, then a period
// the “.” In
the filter is a wildcard and a “\.” matches a “.”–confusing
MyRTR#show run | inc address .\.
ip address 1.1.1.1
255.255.255.0
ip address 2.2.2.2 255.255.255.0
//notice we don’t see 10.1.1.1
The following characters have special meaning in regex and in the filter syntax.
. (Period)
Any Single Character : 임의의 단일문자
* A multiplier that matches 0 or more
sequences of the preceding character
+ A multiplier that matches 1 or more
sequences of the preceding character
? A multiplier that matches 0 or 1 sequences
of the preceding character
^ Matches the start of a line
$ Matches the end of a line
_ Matches Word Boundaries
If you need to match any of these characters, you must escape them in your filter by using a “\.” To quickly see the effect of this issue the following two commands on a router.
MyRTR#show run | inc .
Building configuration…
Current configuration : 740
bytes
!
version 12.3
service timestamps debug datetime
msec
service timestamps log datetime
msec
no service
password-encryption
!
hostname MyRTR
!
boot-start-marker
boot-end-marker
!
< — Snip (it shows everything — >
MyRTR#show run | inc \.
Building configuration…
version 12.3
ip address 1.1.1.1 255.255.255.0
ip address 2.2.2.2
255.255.255.0
ip address 10.1.1.1 255.255.255.0
'General' 카테고리의 다른 글
키보드 자판 부호 이름 (0) | 2016.04.15 |
---|---|
HSRP or VRRP 설정 (0) | 2013.02.06 |