search cancel

Filtering output from commands in Crossbeam CLI and Linux shell


Article ID: 167910


Updated On:




How to use grep and search commands to filter CLI output and how to use Linux shell filtering features to filter the output of CLI commands.N/A


Explain how to filter CLI output using grep and search commands. Also provide examples of some useful commands that can be run from the UNIX prompt to filter the output of CLI commands.


Filtering CLI commands within CLI

It is possible to use search or grep commands in the CLI to filter output of any show command.


The search command provides a simple method to search for single terms within show command output.

search [-exclude] [-case-sensitive] <single_search_term> <show_command>

Example search for an IP address in the running config:

CBS# search 192.168 "show running-config"
  ip route vap-group fw circuit outside


The grep command provides full grep functionality and can be used to search for a complex search term. 

grep [-options <opt1> … <optx>] <search_term> [<show_command>]

Searching for an IP address in show flow active output:

CBS# grep 192.168 "show flow active verbose"
   fw_2 Source Addr, Destination Addr
   np1  Source Addr, Destination Addr

Filter configuration to display IP addresses and related circuits and virtual routers: 

CBS# grep -options -E "^circuit|  ip |virtual" "show running-config"
circuit mgmt circuit-id 1025
    ip increment-per-vap
circuit sync circuit-id 1026
    ip increment-per-vap
circuit inside circuit-id 1027
    ip increment-per-vap
circuit outside circuit-id 1028
    ip increment-per-vap
  virtual-router vrrp-id 1 circuit inside
  virtual-router vrrp-id 2 circuit outside
Filtering CLI commands in Linux shell

Additionally, it is possible to filter output of CLI commands in the Linux shell. The following examples are run from the Linux prompt on the CPM.

Display flows being reported as drops in the AFT (including 2 lines after filtered data):

   /crossbeam/bin/cli -i 'show flow act' |grep -i -A2 drop

Same command but exporting to a file:

   /crossbeam/bin/cli -i 'show flow act' |grep -i -A2 drop > flowdrop.txt

Showing traplog messages for a certain date (including 3 lines after and 4 lines before filtered data) :

   /crossbeam/bin/cli -i 'show traplog' |grep -A3 -B4 2009-11-25

Same command but exporting to a file:

   /crossbeam/bin/cli -i 'show traplog' |grep -A3 -B4 2009-11-25 > nov11trap.txt

Searching for an IP address in running configuration:

   /crossbeam/bin/cli -i 'show running-config" |grep

Search Audit trail for last time the reload command was run:

   /crossbeam/bin/cli -i 'show audit-trail' |grep -i reload

The watch command can also be used to monitor the output of commands.
watch runs command repeatedly, displaying its output (the first screenfull).
This allows you to watch the program output change over time:

   watch --i=2 "/crossbeam/bin/cli -i \"show ap-vap-mapping\""

   watch --i=2 "/crossbeam/bin/cli -i \"show interface gig 1/1\""

   watch --i=2 "/crossbeam/bin/cli -i \"show heartbeat np1\