When you issue commands in operational mode, or when you issue the show command in configuration mode, the output appears on the screen. You can also filter the output of commands, either to perform simple commands on the output or to place the output into a file.
If the output is longer than the screen length, it appears one screen at a time using a UNIX more-type interface. The prompt ---More--- indicates that more output is available. Table 2 lists the keyboard sequences you can use at the ---More--- prompt. As soon as the CLI knows how long the output is (usually by the second screen), it displays the percentage of the command output above the prompt.
For operational and configuration commands that display output, such as the show commands, you can filter the output. When you display help about these commands, one of the options listed is |, called a pipe, which allows you to filter the command output. For example:
user@host>show configuration ?Possible completions: <[Enter]> Execute this command | Pipe through a command user@host> show configuration| ?Possible completions: count Count occurrences except Show only text that does not match a pattern find Search for the first occurrence of a pattern hold Hold text without exiting the ---(more)--- prompt match Show only text that matches a pattern no-more Don't paginate output resolve Resolve IP addresses save Save output text to a file trim Trim specified number of columns from the start line
In configuration mode, two additional filters appear, display and compare:
[edit] user@host #show | ?Possible completions: compare Compare configuration changes with a prior version count Count occurrences display Display additional configuration information except Show only text that does not match a pattern find Search for the first occurrence of a pattern hold Hold text without exiting the ----More--- prompt match Show only text that matches a pattern no-more Don't paginate output resolve Resolve IP addresses save Save output text to a file trim Trim specified number of columns from the start line
The following filtering operations are available:
When the output is very long, when you need to store or analyze the output, or when you need to email or FTP the output, you can place the output of a command into a file. Doing this is useful when the output scrolls off the screen, making it difficult to cut the output from a window and paste it into another.
To save the output to a file, specify the save command after the pipe:
user@host>command| savefilename
By default, the file is placed in your home directory on the router. For information about how you can specify the name of the file, see How to Specify Filenames and URLs.
This example stores the output of the request support information command in a file:
user@host>request support information | savefilenameWrote 1143 lines of output to `filename' user@host>
You can filter the output to search for a text matching a regular expression. You can match a regular expression match everything except a regular expression, or find the first occurrence of text matching a regular expression. All searches are not case-sensitive.
To match a regular expression, specify the match command after the pipe:
user@host>command| matchregular-expression
To ignore text that matches a regular expression, specify the except command after the pipe:
user@host>command| exceptregular-expression
If the regular-expression contains any spaces, operators, or wildcard characters, enclose it in quotation marks.
You use extended regular expressions to specify what text in the output to match. Command regular expressions implement the extended (modern) regular expressions as defined in POSIX 1003.2. Table 3 lists common regular expression operators.
For example, if a command produces the following output:
one two two two three two one four
The match two command displays:
one two two two three two one
The except one command displays:
two two four
List all the ATM interfaces in the configuration:
user@host> show configuration | match at-
at-2/1/0 {
at-2/1/1 {
at-2/2/0 {
at-5/2/0 {
at-5/3/0 {
Display a skeleton of your router configuration:
[edit]
user@host # show | match {
system {
root-authentication {
name-server {
login {
class superuser {
user juniper {
authentication {
services {
syslog {
file messages {
processes {
chassis {
alarm {
sonet {
images {
scb {
fpc {
interfaces {
at-2/1/1 {
atm-options {
unit 0 {
at-2/2/0 {
...
snmp {
community public {
clients {
routing-options {
static {
route 0.0.0.0/0 {
route 192.168.0.0/16 {
route 208.197.169.0/24 {
protocols {
rsvp {
interface so-5/1/0 {
mpls {
interface so-5/1/0 {
bgp {
group internal {
ospf {
area 0.0.0.0 {
interface so-5/1/0 {
List all users who are logged into the router except for the user "root":
user@host>show system users | except root8:28PM up 1 day, 13:59, 2 users, load averages: 0.01, 0.01, 0.00 USER TTY FROM LOGIN@ IDLE WHAT sheep p0 baa.juniper.net 7:25PM - cli
Save the configuration, except for encrypted passwords, to a file:
user@host> show configuration | except SECRET-DATA | save my.output.file
Display the output, starting not at the beginning but rather at the first occurrence of text matching a regular expression, using the find command after the pipe:
user@host>command| findregular-expression
If the regular expression contains spaces, operators, or wildcard characters, enclose the expression in quotation marks.
List the routes in the routing table starting at 208.197.169.0:
user@host> show route | find 208.197.169.0
208.197.169.0/24 *[Static/5] 1d 13:22:11
> to 192.168.4.254 via so-3/0/0.0
224.0.0.5/32 *[OSPF/10] 1d 13:22:12, metric 1
iso.0: 1 destinations, 1 routes (1 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both
47.0005.80ff.f800.0000.0108.0001.1921.6800.4015.00/160
*[Direct/0] 1d 13:22:12
> via lo0.0
In configuration mode only, when you have made changes to the configuration and want to compare the candidate configuration with a prior version, you can use the compare command to display the configuration. The compare command compares the candidate configuration with either the current committed configuration or a configuration file and displays the differences between the two configurations. To compare configurations, specify the compare command after the pipe:
[edit] user@host#show | compare[filename|rollbackn]
filename is the full path to a configuration file. The file must be in the proper format, a hierarchy of statements. For information about how to save a configuration to a file, see Save a Configuration to a File. For information about formatting the hierarchy of statements, see Configuration Statement Hierarchy.
n is the index into the list of previously committed configurations. The most recently saved configuration is number 0, and the oldest saved configuration is number 9. If you do not specify arguments, the candidate configuration is compared against the active configuration file (/config/juniper.conf).
The comparison output uses the following conventions:
The following example shows various changes, then a comparison of the candidate configuration with the active configuration, showing only the changes made at the [edit protocols bgp] hierarchy level.
[edit] user@host#edit protocols bgp[edit protocols bgp] user@host#showgroup "my group" { type internal; hold-time 60; advertise-inactive; allow 1.1.1.1/32; } group fred { allow 2.2.2.2/32; } group "test peers" { type external; allow 3.3.3.3/32; } [edit protocols bgp] user@host#set group "my group" hold-time 90[edit protocols bgp] user@host#delete group "my group" advertise-inactive[edit protocols bgp] user@host#set group fred advertise-inactive[edit protocols bgp] user@host#delete group "test peers"[edit protocols bgp] user@host#show | comparegroup "my group" { type internal; - hold-time 60; + hold-time 90; - advertise-inactive; allow 1.1.1.1/32; } group fred { + advertise-inactive; allow 2.2.2.2/32; } -group "test peers" { - type external; - allow 3.3.3.3/32; -} [edit protocols bgp] user@host#showgroup "my group" { type internal; hold-time 90; allow 1.1.1.1/32; } group fred { advertise-inactive; allow 2.2.2.2/32; }
To show only the changes between the two configurations, use a match command:
user@host# show | compare | match "^[+-]"
To count the number of lines in the output, specify the count command after the pipe:
user@host>command| count
user@host>show configuration | countCount: 269 lines user@host>show route | countCount: 67 lines
To display the output all at once instead of one screen at a time, specify the no-more command after the pipe. This command is equivalent to the set cli screen-length 0 command, but affects the output of the one command only.
user@host>command| no-more
When you view output one screen at a time, you typically return to the CLI prompt after viewing the last screen.
To not return immediately, use the hold command after the pipe. This feature is useful, for example, when you want to scroll or search through the output.
user@host>command| hold
In configuration mode only, to display additional information about the configuration, use the display detail command after the pipe in conjunction with a show command. The additional information includes the help string that explains each configuration statement and the permission bits required to add and modify the configuration statement.
user@host>show<hierarchy-level>| display detail
[edit]
user@host> show | display detail
##
## version: Software version information
## require: system
##
version "3.4R1 [tlim]";
system {
##
## host-name: Host name for this router
## match: ^[[:alnum:]._-]+$
## require: system
##
host-name router-name;
##
## domain-name: Domain name for this router
## match: ^[[:alnum:]._-]+$
## require: system
##
domain-name isp.net;
##
## backup-router: Address of router to use while booting
##
backup-router 192.168.100.1;
root-authentication {
##
## encrypted-password: Crypted password string
##
encrypted-password "$1$BYJQE$/ocQof8pmcm7MSGK0"; # SECRET-DATA
}
##
## name-server: DNS name servers
## require: system
##
name-server {
##
## name-server: DNS name server address
##
208.197.1.0;
}
login {
##
## class: User name (login)
## match: ^[[:alnum:]_-]+$
##
class superuser {
##
## permissions: Set of permitted operation categories
##
permissions all;
}
...
##
## services: System services
## require: system
##
services {
## services: Service name
##
ftp;
##
## services: Service name
##
telnet;
##
}
syslog {
##
## file-name: File to record logging data
##
file messages {
##
## Facility type
## Level name
##
any notice;
##
## Facility type
## Level name
##
authorization info;
}
}
}
chassis {
alarm {
sonet {
##
## lol: Loss of light
## alias: loss-of-light
##
lol red;
}
}
}
}
interfaces {
##
## Interface name
##
at-2/1/1 {
atm-options {
##
## vpi: Virtual path index
## range: 0 .. 255
## maximum-vcs: Maximum number of virtual circuits on this VP
##
vpi 0 maximum-vcs 512;
}
##
## unit: Logical unit number
## range: 0 .. 16384
##
unit 0 {
##
## vci: ATM point-to-point virtual circuit identifier ([vpi.]vci)
## match: ^([[:digit:]]+.){0,1}[[:digit:]]+$
##
vci 0.128;
}
}
...
For the output of a single command, you can filter the output one or more times. For example:
user@host>command| matchregular-expression| exceptregular-expression| matchother-regular-expression| findregular-expression| hold