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

Redirection of show Command Output

You can redirect the output of show commands to network files or local files (in NVS memory) using the redirection operators described in Table 5 .

Table 5: Redirect Operators

Redirect Operator

Use

>

Redirects output to the specified file, overwriting the file if it already exists, creating the file if it does not.

>>

Appends output to the end of the specified file, creating the file if it does not exist.

&>

Redirects output to the specified file, overwriting the file if it already exists, and displays the output on the screen. The redirection is synchronized with the screen display; for example, if a --More-- prompt appears, the redirection halts until you take further action.

&>>

Appends output to the end of the specified file and displays the output to the screen. The redirection is synchronized with the screen display; for example, if a --More-- prompt appears, the redirection halts until you take further action.

For example, you can redirect the output of the show config command to a script file and later run that script:

host1#show config > showconfig.scr

The following command writes the output to a text file, version.txt, on a remote router:

host1#show hardware > pc:/erxfiles/version.txt

The following command appends the output to version.txt:

host1#show hardware >> version.txt

Only one instance of a file can be open for file redirection. An error message is generated if you attempt to redirect output to a file that is already open. You cannot redirect output to a file that includes a local path in the filename.

You can use redirection with output filtering. The general syntax is:

show options [ { > | >> | &> | &>> } filename ]
[ | { begin | include | exclude } filterstring ]

The filtering is performed before redirection. In the following example, the cnfgfltr.txt file will contain the output of show config include-defaults beginning with the first occurrence of the string inter.

host1#show config include-defaults &> cnfgfltr.txt | begin inter

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