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 192.168.4.10/24 192.168.4.255
ip 192.168.4.15/24 192.168.4.255
ip route 192.168.129.0/24 10.10.3.254 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: