Specifying Line Numbers For Search Results; Status Results From The Grep Command - Cisco 11503 - CSS Content Services Switch Administration Manual

Content services switch
Hide thumbs Also See for 11503 - CSS Content Services Switch:
Table of Contents

Advertisement

Chapter 8
Using the CSS Scripting Language

Specifying Line Numbers for Search Results

STATUS Results from the grep Command

OL-5647-02
The search results from a grep command can produce multiple lines. In this case,
you can specify the line number you want to set in the UGREP variable by issuing
grep -u[n], where [n] is an optional line number. By default, the last line of the
search results is saved in the UGREP variable. Suppose that you want to issue a
grep command on the show service command for the service S1 and search for
all the colon (:) characters in the show service screen. For example, enter:
!no echo
show service S1 | grep -u ":"
echo "The line is: ${UGREP}"
The output is:
The line is: Weight: 1
By default, this is the last line in the show service screen that satisfies the search
criteria, but it is not the only line that qualifies. To search for a specific line, for
example the first line that satisfies the search criteria, use the [n] option. For
example, enter:
!no echo
show service S1 | grep -u1 ":"
echo "The line is: ${UGREP}"
The output is:
The line is: Name: S1
This is the first line that satisfies the search criteria. Notice the -u1 option, which
tells the script to search for the colon character (:) and set the UGREP variable
equal to the first qualified search result.
The STATUS code result from the grep command equals the number of qualified
search results. This is important to note because other script commands return a
zero result to indicate success. The grep command returns just the opposite. If it
finds 14 matches, then the STATUS variable is set to 14. If it finds no matches,
then the STATUS variable is set to 0.
Load: 255
Index: 1
Cisco Content Services Switch Administration Guide
Using the grep Command
8-35

Advertisement

Table of Contents
loading

This manual is also suitable for:

11500 series

Table of Contents