Filter and Save Show Output

Save and Filter Show Command Output

You can save the output of show commands by redirecting the output to a text file. You can filter the output of show commands by piping the output to filtering commands.

Saving and filtering output are available with all show commands but are most useful when dealing with commands that produce a lot of text. For example, you can show all or parts of the configuration by using the show configuration command. Copying the configuration output provides a way to backup and restore a configuration.


Note


Show commands do not show the secrets (password fields), so if you want to paste a configuration into a new device, you will have to modify the show output to include the actual passwords.


Filter Show Command Output

To filter the output of a show command, use the following subcommands. Note that in the following syntax description, the initial vertical bar | after the show command is the pipe character and is part of the command, not part of the syntax description. The filtering options are entered after the command’s initial | character.

show command | { begin expression| count| cut expression| egrep expression| end expression| exclude expression| grep expression| head| include expression| last| less| no-more| sort expression| tr expression| uniq expression| wc}

Filtering Options

These are the filtering subcommands:

  • begin —Finds the first line that includes the specified pattern, and display that line and all subsequent lines.

  • count —Counts the number of lines.

  • cut —Removes (“cut”) portions of each line.

  • egrep —Displays only those lines that match the extended-type pattern.

  • end —Ends with the line that matches the pattern.

  • exclude —Excludes all lines that match the pattern and show all other lines.

  • grep —Displays only those lines that match the pattern.

  • head —Displays the first lines.

  • include —Displays only those lines that match the pattern.

  • last —Displays the last lines.

  • less —Filters for paging.

  • no-more —Turns off pagination for command output.

  • sort —Sorts the lines (stream sorter).

  • tr —Translates, squeezes, and/or deletes characters.

  • uniq —Discards all but one of successive identical lines.

  • wc —Displays a count of lines, words, and characters.

expression

An expression, or pattern, is typically a simple text string. Do not enclose the expression in single or double-quotes—these will be seen as part of the expression. Also, trailing spaces will be included in the expression.


Note


Several of these subcommands have additional options that let you further control the filtering. For example, with show configuration | head and show configuration | last, you can use the lines keyword to change the number of lines displayed; the default is 10. As another example, with show configuration | sort, you can add the option -u to remove duplicate lines from the output. (Complete descriptions of these options is beyond the scope of this document; refer to the FXOS help output for the various commands, and to the appropriate Linux help, for more information.)


Examples

The following example shows how to determine the number of lines currently in the system event log:


FP9300-A# show sel 1/1 | count
3008
FP9300-A# 

The following example shows how to display lines from the system event log that include the string “error”:


FP9300-A# show sel 1/1 | include error
968 | 05/15/2016 16:46:25 | CIMC | System Event DDR4_P2_H2_EC
C #0x99 | Upper critical - going high | Asserted | Reading 20
000 >= Threshold 20000 error 
FP9300-A# 

Related Topics

Save Show Command Output

Save Show Command Output

You can save the output of show commands by redirecting the output to a text file.

show command [ > { ftp:| scp:| sftp:| tftp:| volatile: | workspace:} ] | [ >> { volatile: | workspace:} ]

Syntax Description

> { ftp:| scp:| sftp:| tftp:| volatile: | workspace:}

Redirects the show command output to a specified text file using the selected transport protocol.

After you enter the command, you are queried for remote server name or IP address, user name, file path, and so on.

If you press Enter at this point, the output is saved locally.

>> { volatile: | workspace:}

Appends the show command output to the appropriate text file, which must already exist.

Example

The following example attempts to save the current configuration to the system workspace; a configuration file already exists, which you can choose to overwrite or not.

FP9300-A# show configuration > workspace
File already exists, overwrite (y/n)?[n]n
Reissue command with >> if you want to append to existing file

FP9300-A#

Related Topics

Filter Show Command Output