Cisco IOS Shell works on Cisco Routers and Switches.
The Cisco IOS Shell (IOS.sh) feature provides shell scripting capability to the Cisco IOS
command-line-interface (CLI) environment. Cisco IOS.sh enhances the process of controlling and configuring an IOS router using the CLI by including, variable substitution, paths, conditional statements, loops, pipes, and so on to enhance the user experience of Cisco IOS CLI users.
First question: Is IOS.sh router or switch specific? Or are they able
to be used for both types of devices as long as the firmware version
is 15.1 or later?
Cisco IOS Shell was introduced with Cisco IOS Release 15.1(4)M, 15.1(2)S, and later releases for Routers. Cisco IOS.sh must be configured and enabled to use the Cisco IOS.sh features and functions on your router.
I cannot find any documentation explaining when it was introduced into IOS for switches.
Second Question: Now that IOS.sh is enabled, is there a way to use
grep to take a section and output that onto the CLI that I'm looking
at?
The IOS CLI has a facility to 'pipe' text from a command into a set of programs that can filter or redirect the output. The Cisco IOS.sh has expanded this facility to support more than one 'pipe' command on a line of input. The commands are executed concurrently, and print whatever the final command in the 'pipeline' prints.
Example
Router# show version | grep '^C'
Cisco IOS Software, 7200 Software (C7200-P-M), Experimental Version 12.2(20090611:002213)
Copyright (c) 1986-2010 by Cisco Systems, Inc.
Compiled Tue 16-Jun-10 14:23 by janedoe
Cisco 7204VXR (NPE225) processor (revision A) with 114688K/16384K bytes of memory.
Configuration register is 0x0
This example prints all lines that begin with uppercase C.
There's a similar method for the new IOS-XE that is running on Switches, for instance, the Cisco 3650, 3850, 9200, 9300, 9500 Series etc.
This method is called Guestshell, which is a virtualized Linux-based environment, designed to run custom Linux applications, including Python for automated control and management of Cisco devices. It also includes the automated provisioning (Day zero) of systems. This container shell provides a secure environment, decoupled from the host device, in which users can install scripts or software packages and run them.
The following example shows how to enable Guest Shell on a Catalyst 3850 Series Switch:
Device> enable
Device# guestshell enable
Management Interface will be selected if configured
Please wait for completion
Guestshell enabled successfully
Device# guestshell run python
Python 2.7.11 (default, Feb 21 2017, 03:39:40)
[GCC 5.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Device# guestshell run bash
[guestshell@guestshell ~]$
Device# guestshell disable
Guestshell disabled successfully
Device# guestshell destroy
Guestshell destroyed successfully
There's a complete guide on how to use Guestshell for IOS-XE here:
https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/prog/configuration/166/b_166_programmability_cg/guest_shell.html
Please notice, you need to run version 16.6. at least.
Cisco IOS Shell whitepaper:
https://www.cisco.com/c/en/us/td/docs/ios/netmgmt/configuration/guide/Convert/IOS_Shell/nm_ios_shell.pdf
Cisco IOS Shell complete command reference:
https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/ios_shl/command/ios-shell-cr-book/ios-shell-cr-a1.html