CLI Output Filtering Commands
Use these commands to filter CLI command output.
show “command” | include “string”
M4250
M4350
The command show command (that is, you must enter a keyword of an existing show command for the command parameter) is executed and the output is filtered to display only lines containing the string match. All other non-matching lines in the output are suppressed.
Command example:
(NETGEAR Switch) #show running-config | include “spanning-tree”
spanning-tree configuration name "00-02-BC-42-F9-33"
spanning-tree bpduguard
spanning-tree bpdufilter default
show “command” | include “string” exclude “string2”
M4250
M4350
The command show command (that is, you must enter a keyword of an existing show command for the command parameter) is executed and the output is filtered to only show lines containing the string match and not containing the string2 match. All other non-matching lines in the output are suppressed. If a line of output contains both the include and exclude strings then the line is not displayed.
Command example:
(NETGEAR Switch) #show running-config | include “spanning-tree” exclude “configuration”
spanning-tree bpduguard
spanning-tree bpdufilter default
show “command” | exclude “string”
M4250
M4350
The command show command (that is, you must enter a keyword of an existing show command for the command parameter) is executed and the output is filtered to show all lines not containing the string match. Output lines containing the string match are suppressed.
Command example:
(NETGEAR Switch) #show interface 0/1
Packets Received Without Error................. 0
Packets Received With Error.................... 0
Broadcast Packets Received..................... 0
Receive Packets Discarded...................... 0
Packets Transmitted Without Errors............. 0
Transmit Packets Discarded..................... 0
Transmit Packet Errors......................... 0
Collision Frames............................... 0
Time Since Counters Last Cleared............... 281 day 4 hr 9 min 0 sec
Command example:
(NETGEAR Switch) #show interface 0/1 | exclude “Packets”
Transmit Packet Errors......................... 0
Collision Frames............................... 0
Time Since Counters Last Cleared............... 20 day 21 hr 30 min 9 sec
show “command” | begin “string”
M4250
M4350
The command show command (that is, you must enter a keyword of an existing show command for the command parameter) is executed and the output is filtered to show all lines beginning with and following the first line containing the string match. All prior lines are suppressed.
Command example:
(NETGEAR Switch) #show port all | begin “1/1”
1/1 Enable Down Disable N/A N/A
1/2 Enable Down Disable N/A N/A
1/3 Enable Down Disable N/A N/A
1/4 Enable Down Disable N/A N/A
1/5 Enable Down Disable N/A N/A
1/6 Enable Down Disable N/A N/A
show “command” | section “string”
M4250
M4350
The command show command (that is, you must enter a keyword of an existing show command for the command parameter) is executed and the output is filtered to show only lines included within the section(s) identified by lines containing the string match and ending with the first line containing the default end-of-section identifier (that is, exit).
Command example:
(NETGEAR Switch) #show running-config | section “interface 0/1”
interface 0/1
no spanning-tree port mode
exit
show “command” | section “string” “string2”
M4250
M4350
The command show command (that is, you must enter a keyword of an existing show command for the command parameter) is executed and the output is filtered to only show lines included within the section(s) identified by lines containing the string match and ending with the first line containing the string2 match. If multiple sessions matching the specified string match criteria are part of the base output, then all instances are displayed.
show “command” | section “string” include “string2”
M4250
M4350
The command show command (that is, you must enter a keyword of an existing show command for the command parameter) is executed and the output is filtered to only show lines included within the section(s) identified by lines containing the string match and ending with the first line containing the default end-of-section identifier (that is, exit) and that include the string2 match. This type of filter command could also include “exclude” or user-defined end-of-section identifier parameters as well.