For instance, if you want to quickly return only 10G interfaces names in up ‘state’ you can use following command: Moreover, once you activated IOS.sh you can build long pipeline consists of multiple ‘grep’ functions. v - invert match, print non-matching lines u - match everything in a file until pattern n - print line numbers along with matches h - do not print filename for each match (default) e - use as the pattern (it may have a leading minus) c - print a count of lines instead of matched lines b - match everything in a file after pattern With the supplied regular expression, and prints matching The 'grep' command matches lines in the given files Information about particular built-in function can be retrieved by using command: ‘man’ with a name of a function.Īmong other helpful features, IOS.sh allows to use ‘grep’ utility after pipe with the following available options: To show which built-in functions are available in IOS.sh, enter ‘show shell functions brief’: It can be done by entering ‘terminal shell’ exec-command for current session or by ‘shell processing full’ global-configuration command for current and any future sessions. Next thing that might be useful for solving this issue is activating full bash-like capabilities called IOS.sh on your Cisco IOS device. IOS# show running-config | include interface|switchport access vlan 201 Using ‘include’ function and logical OR operator (this possible solution can first come to your mind) does not solve the problem: Let us imagine that we want to parse running configuration of a switch and show full configuration of only those interface configuration sections that configured with command ‘switchport access vlan 201’. While such piping functions as ‘begin’, ‘exclude’, ‘include’, ‘redirect’ and ‘section’ support regular expression as an argument, it may be not enough for some advanced tasks. This page at Cisco official documentation web site explains how the IOS piping functions work and provide some representative examples. IOS Native CLIĬisco IOS by default provides very basic parsing functions:Īppend Append redirected output to URL (URLs supporting append operation only)Ĭount Count number of lines which match regexpįormat Format the output using the specified spec file By search capabilities, I imply abilities to filter output of CLI show/more/dir/etc commands using pipeline. In this article, I would like to show the difference in search capabilities at the most “CLIish” Cisco OS: IOS, IOS-XE and NX-OS as well as give you an idea how it can be customized and improved. While some of Cisco operating systems have powerful search engine, other by default offer vary basic search functions. However, it is worth mentioning that many configuration tasks require parsing of output of different commands including configuration on devices at real time. Indeed, we have been learning how to generate text configuration leveraging different programming languages, apply commands using Ansible or simply modify configuration templates using Notepad++ regexp replacement. Of course, we, as network engineers, have mastered how to automate these scenarios. Network professionals working with variety of Cisco switches, routers and firewalls on daily basis know that vast majority of configuration scenarios one way or another involves interaction with command line interface.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |