The 7210 SAS devices support the pipe feature to search one or more files for a specific character string or pattern.
When using the pipe/match command the variables and attributes must be spelled correctly. The attributes following the command and must come before the expression/pattern. The following are examples of the pipe/match command to complete different tasks:
Task - Capture all the lines that include ‟echo” and redirect the output to a file on the compact flash:
admin display-config | match ‟echo” > cf3 cf1:\echo_list.txt
Task - Display all the lines that do not include ‟echo”:
admin display-config | match invert-match ‟echo”
Task - Display the first match of ‟vpls” in the configuration file:
admin display-config | match max-count 1 ‟vpls”
Task - Display everything in the configuration after finding the first instance of ‟interface”:
admin display-config | match post-lines 999999 interface
Command syntax:
match pattern context {parents | children | all} [ignore-case] [max-count lines-count] [expression]
match pattern [ignore-case] [invert-match] [pre-lines pre-lines] [post-lines lines-count] [max-count lines-count] [expression]
where:
pattern string or regular expression
context keyword: display context associated with the matching line
parents keyword: display parent context information
children keyword: display child context information
all keyword: display both parent and child context information
ignore-case keyword
max-count keyword: display only a specific number of instances of matching lines
lines-count 1 — 2147483647
expression keyword: pattern is interpreted as a regular expression
invert-match keyword
pre-lines keyword: display some lines prior to the matching line
pre-lines 0 — 100
post-lines keyword: display some lines after the matching line
lines-count 1 — 2147483647
*A:Dut-G# show log log-id 99 | match ignore-case sap
"Processing of an access port state change event is finished and the status of all
affected SAPs on port 1/1/21 has been updated."
"Service Id 4001, SAP Id 1/1/21:0.* configuration modified"
A:Dut-C# show log log-id 98 | match max-count 1 "service 1001"
"Status of service 1001 (customer 1) changed to administrative state: up, operationa
l state: up"
*A:Dut-G# admin display-config | match post-lines 4 max-count 2 expression "vpls"
#--------------------------------------------------
...
vpls 1 customer 1 svc-sap-type null-star create
description "Default tls description for service id 1"
stp
shutdown
exit
vpls 2 customer 1 svc-sap-type null-star create
description "Default tls description for service id 2"
stp
shutdown
exit
...
#--------------------------------------------------
The following table describes regular expression symbols and interpretation (similar to what is used for route policy regexp matching). Table: Special characters describes special characters.
String |
Description |
---|---|
. |
Matches any single character. |
[ ] |
Matches a single character that is contained within the brackets. [abc] matches ‟a”, ‟b”, or ‟c”. [a-z] matches any lowercase letter. [A-Z] matches any uppercase letter. [0-9] matches any number. |
[^ ] |
Matches a single character that is not contained within the brackets. [^abc] matches any character other than ‟a”, ‟b”, or ‟c”. [^a-z] matches any single character that is not a lowercase letter. |
^ |
Matches the start of the line (or any line, when applied in multiline mode) |
$ |
Matches the end of the line (or any line, when applied in multiline mode) |
() |
Define a ‟marked subexpression”. Every matched instance will be available to the next command as a variable. |
* |
A single character expression followed by ‟*” matches zero or more copies of the expression. |
{m,n} |
Matches at least m and at most n repetitions of the term |
{m} |
Matches exactly m repetitions of the term |
{m,} |
Matches m or more repetitions of the term |
? |
The preceding item is optional and matched at most once. |
+ |
The preceding item is matched one or more times. |
- |
Used between start and end of a range. |
\ |
An escape character to indicate that the following character is a match criteria and not a grouping delimiter. |
> |
Redirect output |
Options |
Similar to |
Description |
---|---|---|
[:upper:] |
[A-Z] |
uppercase letters |
[:lower:] |
[a-z] |
lowercase letters |
[:alpha:] |
[A-Za-z] |
upper- and lowercase letters |
\w |
[A-Za-z_] |
word characters |
[:alnum:] |
[A-Za-z0-9] |
digits, upper- and lowercase letters |
[:digit:] |
[0-9] |
digits |
\d |
[0-9] |
digits |
[:xdigit:] |
[0-9A-Fa-f] |
hexadecimal digits |
[:punct:] |
[.,!?:...] |
punctuation |
[:blank:] |
[ \t] |
space and TAB |
[:space:] |
[ \t\n\r\f\v] |
blank characters |
\s |
[ \t\n\r\f\v] |
blank characters |