CLI Usage
Basic System Configuration Guide 31
Pipe/Match
The SR OS supports the pipe feature to search one or more files for a given character string
or pattern.
When using the pipe/match command the variables and attributes must be spelled correctly.
The attributes follow the command and must come before the expression/pattern. The
following are examples of how to use 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” > cf1:\test\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
• Task: Display a count of the total number of lines of output instead of displaying the
output itself.
admin display-config | match interface | count
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