How to Control the Command Output Display in Junos OS - dummies

How to Control the Command Output Display in Junos OS

By Walter J. Goralski, Cathy Gadecki, Michael Bushong

Juniper’s Junos Command Line Interface (CLI) offers you a great deal of flexibility in displaying output. For example, you can request output in different formats, specify how to show more, and pipe (|) the output to display exactly what you want.

Choose your display format

The Junos operational mode show commands commonly include these display options: terse, brief, detail, and extensive (where the commands are listed from the least to the most displayed output). You can use these options to adjust the show output listings according to what you need.

For example, compare the output when adding terse and brief to the following show interfaces command:

wiley@netnik> show interfaces fe-1/1/1 terse
Interface Admin Link Proto Local Remote
fe-1/1/1 up up
at-1/3/0.0 up up inet →
wiley@netnik> show interfaces fe-1/1/1 brief
Physical interface: fe-1/1/1 Enabled, Physic link is Down
Link-level type:Ethernet, MTU: 1514, Spped: 100mbps, Loopback:
Disabled, Source filtering: Disabled
Flow control : Enabled
Device flags : Present Running Down
Interface flags: Hardware-Down SNMP-Traps Internal: Ox4000
Link flags : None

Paginate the output on the screen

The Junos CLI display screen automatically paginates output, including the <more> prompt as the last line. Press the h key at any <more> prompt to ask for help and list the options, such as moving forward and backward in the output, searching, and saving.

Use the pipe command tool

Pipe (|) is among the most powerful command tools in Junos. With this command tool, you can select a specific subset of output in a single command step. Become familiar with using pipe, and you’ll save yourself hours of tedium reading and parsing through long lists of output.

Let Junos do the work by giving you just the output you want. In Junos, both operational and configuration mode commands include options for using pipe to modify the output.

The key to understanding pipe is to remember that the output of the command to the left of the pipe symbol serves as input to the command (or file) to the right of the pipe.

The power of pipe to combine commands creates its superb utility. You can query the CLI to find valid ways to pipe a command.

wiley@netnik> show route | ?
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

A few examples from a configured device are the best way to learn about pipe in operational mode.

Limit the output

The most common ways to use the pipe (|) symbol is to constrain the output using match, except, find, or last:

  • | match: Specifies exactly what you want to display:

    wiley@netnik > show configuration | match 
    at-2/1/0 {
    at-2/1/1 {
    at-2/2/0 {
    at-5/2/0 {
               at-5/3/0 {
  • | except: Displays output that ignores a specific string:

    wiley@netnik> show system users | except root
    8:28PM up 1 day, 13:59, 2 users, load averages:
    0.01, 0.01, 0.00
    wiley.netnik 7:25PM - cli
  • | find: Displays output starting at the first occurrence of the matching text:

    wiley@netnik> show ethernet-switching interfaces detail | find “Index: 80”
    Interface: ge-0/0/16.0 Index: 80
  • | last: Displays only the last screen of the listing:

wiley@netnik> show ethernet-switching interfaces detail | last
Interface: ge-0/0/16.0 Index: 80

Count lines of output

You can also use pipe with show commands to change the type of output. For example, | count gives the number of lines in the output:

wiley@netnik> show interfaces terse | count
Count: 27 lines

You can use more than one pipe character in a single command. The Junos OS views the multiple pipes as a logical AND; it displays the output that matches all the pipes. For example, you can determine the total number of configured Fast Ethernet interfaces with the following command:

wiley@netnik> show interfaces terse | match fe- | count
Count: 14 lines

Output to file

Using pipe, you can also create a file that stores the output of a command, for example:

wiley@netnik> request support information | save <filename>

Wrote 1143 lines of output to ’filename’