HPE/Aruba-OS Switch - How To Use The Pipe(|) Option To Filter "Show" Command Output In The CLI

By esupport posted Sep 28, 2020 09:37 AM

  
Q:

When running a "Show" command, can I filter the output to show only what I am looking for?



A:

When viewing "Show" command output from the Command Line Interface, the Pipe (|) option can be used to filter the output and view lines that contain specific words.
It can also be used to filter out certain words that don't need to be seen in the output.
  
Details:
Pipe Option Syntax With "Show" Command:
When running any "Show" commands in the switch Command Line Interface, the Pipe option is available to filter the output.
This filter can be used to include or exclude specific words from the output.

After typing in the "show" command, add the Pipe symbol and then the include or exclude option followed by the filter word(s).
      show <command> | include <filter>       (i=include)
      show <command> | exclude <filter>       (e=exclude)

The letter "i" or "e" can be used instead of typing in the full word "include" or "exclude".
    *Note - The i (include) and e (exclude) are case sensitive and must be typed in lower-case.
    *Also Note - The filter word(s) are also case-sensitive and must match what shows in the normal output.

Most often, the filter words will start with a capital letter.
Be sure to check the full "show <command>" output for the correct syntax and match that exact syntax with your filter.
    
The Pipe symbol can be added between multiple words when filtering on multiple words:
      show <command> | i xxxxx|yyyyy
      show <command> | e xxxxx|yyyyy|zzzzz
      
Pipe Option Syntax With "Show Logging" Command:
When filtering output from the switch event logs, the Pipe option may be optional.
To filter the event log by specific words, the "show log <filter>" command can be used, or the "show log | include/exclude <filter>" command can be used.
If filtering on a single word that must be included, the Pipe option is not needed.
If filtering on multiple words or when using the exclude filter, the Pipe option is needed.
    
Filtering the Event Log by specific words:
show log <filter>
 or
show log | i <filter>       (i=include)
show log | e <filter>       (e=exclude)
    *Note - The (i) for include and (e) for exclude are case-sensitive and must be in lower-case.
    *Also Note - The filter words are case-sensitive and must match the case syntax shown in the log output.  
      Be sure to check the full "show logging" output for the correct syntax and match that exact syntax with your filter.
      
The Pipe symbol can be added between multiple words when filtering on multiple words:
      show log | i xxxxx|yyyyy
      show log | e xxxxx|yyyyy|zzzzz
      
Example "Show" Command Syntax:
  
If I want to view all the ports that are delivering Power to PoE connected devices, I could run the following command:
        show power brief | i Delivering  

Or, if I want to show the descriptor lines above my output, I could use the following:
        show power brief | e Searching
                  
If I want to see if any ports are being blocked by spanning-tree, I could run the following command:
        show span | i Blocking
                
If I want to see if any ports are running in half-duplex, I could run the following command:
        show int brief | i HDx
                
If I want to see what ports are currently online, I could run the following command:
        show int brief | i Up

Or, if I want to show the descriptor lines above my output, I could use:
        show int brief | e Down
                 
If I want to see what ports are 10 gig ports, I could run the following command:
        show int brief | i 10G
                
If I want to see what mac-address is connected to port, I could run the following command:
        show mac-address | i <port#>
        
If I want to see if the switch recognizes an IP address for a port, I could run the following command:
        show arp | i <port#>
     
Example "Show Logging" Syntax:
    
If I want to view any events that have the word Broadcast, I could use the following command:
        show log Broadcast

This would give me the same output as if I used the pipe option and included the word Broadcast:
        show log | i Broadcast
      
The pipe option can be useful with event log output when trying to find multiple words or when excluding certain output.
If I want to view all the event logs that include the words Broadcast or Power, I could use the following command:
        show log | i Broadcast|Power
      -  this shows me the output for all Power related events and any Broadcast storms that occurred.
      
Often times there are hundreds of events related to ports coming online or going offline, which are often generated when devices are powered on or off each day.
If I want to view the entire event log, but don't want to show the hundreds of port off-line, port on-line, and Blocked by STP events, I could use the following command:
        show log -a | e off-line|on-line|Blocked
      -  this shows me all the events minus the normal events associated with a port toggle.

0 comments
0 views