XG700 User's Guide
19/266
All Rights Reserved, Copyright (C) PFU LIMITED 2005-2006
2.2.10 Filtering show Command Output
This function allows you to filter show command outputs to extract the lines that satisfy specific conditions (filter for strings).
This function is useful in excluding unnecessary information from a large amount of output.
To use it, a "show" command must be followed by a keyword (pipe (|), begin, include or exclude) and a regular expression
(filtering condition).
Syntax
show | {begin | include | exclude} regular-expression
Keyword for filtering output
Meaning
begin
Begins output starting at the first line that matches given regular expression parameters.
exclude
Displays output lines that do not contain those lines that match given regular expression
parameters.
include
Displays output lines that match given regular expression parameters.
xg# show history | begin 2
...skipping
2 configure terminal
3 show running-config
4 show history
5 show history | begin 2
xg# show history | exclude 2
1 enable
3 show users
4 show history
xg# show history | include 2
2 configure terminal
5 show history | begin 2
Regular expressions are case sensitive.
For example, if you enter "| exclude strings", lines that include "String" are output, but those that include "strings" are not.
2.2.11 Redirecting show Command Output
You can redirect the output of "show" commands to a file in volatile memory using ">" or "| redirect".
Syntax (To redirect the output of a show command to a file in volatile memory:)
show > FILE-NAME
show | redirect FILE-NAME
FILE-NAME
Specify a file name in the volatile memory to which the output of the command is redirected.
"| tftp" allows you to directly redirect the output of a show command to a file in a TFTP server.
Syntax (To directly redirect the output of a show command to a file in a TFTP server:)
show | tftp HOST REMOTE-FILE
HOST
Specify a host name or IP address of the TFTP server.
REMOTE-FILE
Specify the file name in the TFTP server to which the output of the command is redirected.
In the following example, the current startup-config is redirected as filename "startup_09302005", the running-config file is
redirected as filename "running_09302005", and system information is redirected as filename "system_09302005".
The results of the redirection are confirmed with the "ls" command.
Then, using the "tftp" command, each of these files is moved to the TFTP server.
xg# show startup-config > startup_09302005
xg# show running-config > running_09302005
xg# show system information > system_09302005
xg# ls
(ls command output)
Update-time File-size File-name
- 2005/09/30 11:57:27 872 system_09302005
- 2005/09/30 11:54:01 2,310 startup_09302005
- 2005/09/30 11:55:58 2,437 running_09302005
xg# tftp put remote-host1 startup_09302005 restore_startup_09302005
xg# tftp put remote-host1 running_09302005 restore_running_09302005
xg# tftp put remote-host1 system_09302005 restore_system_09302005
In the following example, show command output is directly redirected to TFTP server "remote-host1" using "| tftp".
xg# show startup-config | tftp remote-host1 restore_ startup_09302005
xg# show running-config | tftp remote-host1 restore_running_09302005
xg# show system information | tftp remote-host1 restore_system_09302005