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


Using the Pipe ( | ) Symbol When Entering Commands

You can filter output by adding the | (pipe) symbol when you enter a command. For example, you can use the pipe symbol after show configuration:

user@host> show configuration ?
Possible completions:
  <[Enter]>            Execute this command
> interfaces           Interfaces on the SDX platform
> policies             Policy configuration
> redirect-server      Redirect server properties
> routing-options      Protocol-independent routing option configuration
> services             Service configuration
> shared               Shared configuration
> slot                 Component configuration
> snmp                 SNMP agent
> subscribers          Subscriber and subscription configuration
> system               System parameters
|                    Pipe through a command

The following example lists the filters that can be used with the pipe symbol:

user@host> show configuration | ?
Possible completions:
  count                Count occurrences
  display              Show additional kinds of information
  except               Show only text that does not match a pattern
  find                 Search for first occurrence of the pattern
  last                 Display end of output only
  match                Show only text that does match a pattern
  no-more              Do not paginate output
  save                 Save output text to file

You can enter any of the pipe filters in conjunction. For example:

user@host> command | match regular-expression | save filename

See Pipe Filter Functions for a description of each type of filter.

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 12.) If the regular expression contains spaces, operators, or wildcard characters, enclose the expression in quotation marks.

Table 12: 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


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