S/N/K-Series Search for Matching Output in 'show' commands

  • 14 January 2015
  • 0 replies
  • 224 views

Userlevel 3
Article ID: 14877

Products
S-Series
Matrix N-Series DFE
K-Series

Goals
Search for matching output in '
code:
show
' commands, similar to the use of the UNIX '
code:
grep
' parameter.
Use the pipe character to locate keywords in query command output.

Solution
Most '
code:
show
' commands are responsive to appending of the "
code:
|find
<[code]keyword[/code]>" sequence, which provides filtering that has the effect of only displaying output lines that include the specified keyword string.

Here are some examples:

code:
N7(su)-
>[code]show config policy |find cos 6[/code]
code:
set policy profile 1 name QoS pvid-status enable pvid 4095 cos-status enable cos 6

code:
set policy rule 1 iptos 104 mask 8 forward cos 6

code:
set policy rule 1 iptos 184 mask 8 forward cos 6

code:
N7(su)-
>

code:
N7(su)-
>[code]show config all |find cos 6[/code]
code:
set policy profile 1 name QoS pvid-status enable pvid 4095 cos-status enable cos

code:
6 tci-overwrite disable precedence 1-8,12-19,21-22,25-28,31 clear-mirror syslog

code:
disable trap disable disable-port disable

code:
set policy rule 1 iptos 104 mask 8 storage-type non-volatile forward cos 6 syslo

code:
g disable trap disable disable-port disable tci-overwrite disable clear-mirror

code:
set policy rule 1 iptos 184 mask 8 storage-type non-volatile forward cos 6 syslo

code:
g disable trap disable disable-port disable tci-overwrite disable clear-mirror

code:
N7(su)-
>

code:
N5(su)-
>[code]show system hardware |find sdram[/code]
code:
SDRAM:
code:
256 MB

code:
SDRAM:
code:
256 MB

code:
SDRAM:
code:
256 MB

code:
N5(su)-
>

code:
N7(su)-
>[code]show port lacp port *.*.* status summary |find lag[/code]
code:
fe.1.22
code:
lag.0.1 [(32768,001188162793,32768),(32768,001f453d21aa,32768)]

code:
fe.1.24
code:
lag.0.1 [(32768,001188162793,32768),(32768,001f453d21aa,32768)]

code:
N7(su)-
>

code:
N7(su)-
>[code]show logging buffer |find ge.1.23[/code]
<
code:
165
>
code:
Dec 13 21:36:47 10.20.1.150 LinkTrap[1]Interface ge.1.23 is Up.

<
code:
165
>
code:
Dec 13 21:36:49 10.20.1.150 LinkTrap[1]Interface ge.1.23 is Down.

<
code:
165
>
code:
Dec 13 21:36:53 10.20.1.150 LinkTrap[1]Interface ge.1.23 is Up.

<
code:
165
>
code:
Dec 17 17:55:25 10.20.1.150 LinkTrap[1]Interface ge.1.23 is Down.

<
code:
165
>
code:
Dec 20 20:04:13 10.20.1.150 LinkTrap[1]Interface ge.1.23 is Up.

code:
N7(su)-
>

code:
S4(su)-
>[code]show router limits |find interfaces[/code]
code:
ip-interfaces 278 - - -

code:
lo-interfaces 1 - - -

code:
lpbk-interfaces 21 - - -

code:
vlan-interfaces 256 - - -

code:
S4(su)-
>

code:
S4(su-router)-
>[code]show ip ospf database |find 0.0.0.0[/code]
code:
Displaying LS Type 1 Advertisements (Area 0.0.0.0)

code:
Displaying LS Type 2 Advertisements (Area 0.0.0.0)

code:
Displaying LS Type 3 Advertisements (Area 0.0.0.0)

code:
Displaying LS Type 4 Advertisements (Area 0.0.0.0)

code:
0.0.0.0 140.161.254.1 398 800020c2 0xa4b4

code:
S4(su-router)-
>

Here are some pointers for use of this command feature:
  • It simply filters output lines not containing an exact match to the <[code]keyword[/code]> string value. If that string value does not appear when the command is executed without "[code]|find[/code]", then there will be no output when the command is executed with "[code]|find[/code]".
  • None of the command menu system, including the help menus, make mention of it.
  • None of the official documentation, including manuals and release notes, make mention of it.
  • There is no list of commands that either support it or don't support it. If not supported for a particular '[code]show[/code]' command, then its inclusion with that command is simply ignored - no error message is generated.
  • The keyword is not case sensitive.
  • Do not add delimiters (e.g. [code]""[/code]) to the keyword string, even if it includes spaces or special characters. Any included delimiters are assumed to be part of the keyword string value.
  • "[code]|find[/code]" only works while CLI length is set to [code]0[/code] (default). If "[code]|find[/code]" is used while length is greater than [code]0[/code] (e.g. '[code]set length 24[/code]'), then both of these features are ignored during the '[code]show[/code]' command execution. This is a known shortcoming, effectively FAD. It may be resolved in a future firmware release.
Also see this HowTo Video which explains the use of the Find and Loop parameters.

0 replies

Be the first to reply!

Reply