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

Using the Pipe ( | ) Symbol When Entering Commands

You can filter output by adding the | (or pipe) symbol when you enter a command. For example:


user@host> show rip neighbor ?
Possible completions:
  <[Enter]>            Execute this command
                 Name of RIP neighbor
  instance             Name of RIP instance
  logical-router       Name of logical router, or 'all'
  |                    Pipe through a command

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


user@host> show rip neighbor | ?
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 pattern
  hold                 Hold text without exiting the --More-- prompt
  last                 Display end of output only
  match                Show only text that matches a pattern
  no-more              Don't paginate output
  request              Make system-level requests
  resolve              Resolve IP addresses
  save                 Save output text to file
  trim                 Trim specified number of columns from start of line

For the show configuration command only, an additional compare filter is available:


user@host> show configuration | ?
Possible completions:
  compare              Compare configuration changes with prior version
...

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.

Note: This section describes only the filters that can be used for operational mode command output. For information about filters that can be used in configuration mode, see the JUNOS System Basics Configuration Guide.

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

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

and a pipe filter of | except 1 displays the following output:

2 2
4

 

Note: See the following sections for more examples of using regular expressions:

Pipe Filter Functions

This section describes each pipe filter:


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