[Contents] [Prev] [Next] [Index] [Report an Error]

## Using Regular Expressions with the Pipe Symbol

The except, find, and match filters used with the pipe symbol employ regular expressions to filter output. Juniper Networks uses the regular expressions as defined in POSIX 1003.2. (See Table 11.) If the regular expression contains spaces, operators, or wildcard characters, enclose the expression in quotation marks.

Table 11: Common Regular Expression Operators in Operational Mode Commands

Operator | Function
--- | ---
| | Indicates that a match can be one of the two terms on either side of the pipe.
^ | Used at the beginning of an expression, denotes where a match should begin.
$ | Used at the end of an expression, denotes that a term must be matched exactly up to the point of the $ character.
[ ] | Specifies a range of letters or digits to match. To separate the start and end of a range, use a hyphen ( - ).
( ) | Specifies a group of terms to match.

For example, if a command produces the following output:

`

1 2
2 2
3 2 1
4

`

A pipe filter of | match 2 displays the following output:

`

1 2
2 2
3 2 1

`

A pipe filter of | except 1 displays the following output:

`

2 2
4

`

#### Related Topics

- Using the Pipe ( | ) Symbol When Entering Commands
- Disregarding Output That Does Not Match a Regular Expression
- Displaying Output from the First Match of a Regular Expression
- Displaying Output That Matches a Regular Expression
- Saving Output to a File

[Contents] [Prev] [Next] [Index] [Report an Error]