Using Pipe Filter Functions
You can perform the following tasks by using the pipe filter:
Counting the Number of Lines of Output
To count the number of lines in the output from a command:
Enter count after the pipe symbol.
For example:
user@host> show configuration | count Count: 369 lines
Displaying Summarized Output for a Hierarchy Level (SRC CLI)
To display the summarized output of the display level command along with the show command:
The level filter specifies the configuration level for which the summarized output is displayed.
The following example displays the show | display level 1 command output for the hierarchy level 1:
[edit shared] user@host# show | display level 1
acp; auth-cache; network; nic; sae;
Displaying Output in XML Tag Format
To display command output in XML tag format:
Enter display xml after the pipe symbol.
The following example displays the show cli directory command output as XML tags:
user@host> show cli directory | display xml <?xml version="1.0"?> <output> Current directory: /root </output>
Disregarding Output That Does Not Match a Regular Expression
If the regular expression contains any spaces, operators, or wildcard characters, enclose it in quotation marks.
For information about common regular expression operators, see table Common Regular Expression Operators in Operational Mode Commands in Using Regular Expressions with the Pipe Symbol.
To disregard text that matches a regular expression:
Specify the except command after the pipe symbol.
The following example displays information about configuration interfaces with the exception of the family information for each interface:
user@host> show configuration interfaces |except family lo { unit 0 { inet { address 192.0.0.1; } } } } eth0 { unit 0 { inet { address 10.27.7.45/24; } } } }
Displaying Output from the First Match of a Regular Expression
When you use regular expressions, enclose any spaces, operators, or wildcard characters in quotation marks.
For information about common regular expression operators, see table Common Regular Expression Operators in Operational Mode Commands in Using Regular Expressions with the Pipe Symbol.
To display output starting with the first occurrence of text matching a regular expression:
Enter find after the pipe symbol.
The following example starts displaying information for the show system information command starting with the Current time section of the output:
user@host> show system information |find time Current time 2006-10-31 09:34:17 EST Uptime 11 days, 17:26 Number of active users 2 Load Averages (1m/5m/15m) 0.09/0.08/0.09
Memory Total 15G Free 14G
CPU Info Number of CPU Core(s) 4 CPU Model Dual Core AMD Opteron(tm) Processor 265 Clock Speed 1804.137 MHz
Disk Information Mountpoint Total Used Use% / 2015M 1018M 50% /altroot 2015M 1015M 50% /boot 98M 14M 14% /var 5039M 497M 9%
. . .
Displaying the End of the Output for a Command
To display the end of the output for a command:
Enter last after the pipe symbol.
The following example shows the end of the output for the show system information command.
user@host> show system information |last Temperature System 30.000 degrees C Physical CPU-1 34.000 degrees C Physical CPU-2 29.000 degrees C
Fan Speed Fan-1 9375 RPM Fan-2 9375 RPM
Displaying Output That Matches a Regular Expression
If the regular expression contains any spaces, operators, or wildcard characters, enclose it in quotation marks.
For information about common regular expression operators, see table Common Regular Expression Operators in Operational Mode Commands in Using Regular Expressions with the Pipe Symbol.
To display output that matches a regular expression:
Enter match regular-expression after the pipe symbol.
The following example matches all Ethernet interfaces in the interface configuration:
user@host> show configuration interfaces | match eth eth0 {
Preventing Output from Being Paginated
By default, if output is longer than the length of the terminal screen, a MORE message lets you display the remaining output when you press the Spacebar. You can use the | no-more filter to display all output at once. This feature is useful when you want access to the entire output, such as to copy the entire output and paste it into an e-mail message.
To prevent the output from being paginated:
Enter no-more after the pipe symbol.
For example, to display all output from the show configuration command at once:
user@host> show configuration | no-more
Saving Output to a File
When command output is lengthy, when you need to store or analyze the output, or when you need to send the output in an e-mail or by FTP, you can save the output to a file.
When you run a show command, your SRC privileges determine the information that you view. Therefore, when you save this information, you are saving only the configuration information that you have privileges to view.
By default, the file is placed in the current working directory of the CLI.
To save command output to a file:
Enter save filename after the pipe symbol.
The following example saves the output from the show command to a file named my-config-info.txt:
[edit system] user@host> show | save my-config-info.txt Wrote 78 lines of output to ‘my-config-info.txt’ user@host>