NAME
lsearch - See if a list contains a particular element
SYNOPSIS
lsearch ?options? list pattern
DESCRIPTION
-ascii
-decreasing
-dictionary
-exact
-increasing
-integer
-glob
-real
-regexp
-sorted
KEYWORDS

NAME

lsearch - See if a list contains a particular element

SYNOPSIS

lsearch ?options? list pattern

DESCRIPTION

This command searches the elements of list to see if one of them matches pattern. If so, the command returns the index of the first matching element. If not, the command returns -1. The option arguments indicates how the elements of the list are to be matched against pattern and it must have one of the following values:

-ascii
The list elements are to be examined as ASCII strings. This option is only meaningful when used with -exact or -sorted.

-decreasing
The list elements are sorted in decreasing order. This option is only meaningful when used with -sorted.

-dictionary
The list elements are to be compared using dictionary-style comparisons. This option is only meaningful when used with -exact or -sorted.

-exact
The list element must contain exactly the same string as pattern.

-increasing
The list elements are sorted in increasing order. This option is only meaningful when used with -sorted.

-integer
The list elements are to be compared as integers. This option is only meaningful when used with -exact or -sorted.

-glob
Pattern is a glob-style pattern which is matched against each list element using the same rules as the string match command.

-real
The list elements are to be compared as floating-point values. This option is only meaningful when used with -exact or -sorted.

-regexp
Pattern is treated as a regular expression and matched against each list element using the rules described in the re_syntax reference page.

-sorted
The list elements are in sorted order. If this option is specified, lsearch will use a more efficient searching algorithm to search list. If no other options are specified, list is assumed to be sorted in increasing order, and to contain ASCII strings. This option cannot be used with -glob or -regexp.

If option is omitted then it defaults to -glob. If more than one of -exact, -glob, -regexp, and -sorted is specified, whichever option is specified last takes precendence. If more than one of -ascii, -dictionary, -integer and -real is specified, the option specified last takes precendence. If more than one of -increasing and -decreasing is specified, the option specified last takes precedence.

KEYWORDS

list, match, pattern, regular expression, search, string
Copyright © 1993 The Regents of the University of California.
Copyright © 1994-1996 Sun Microsystems, Inc.
Copyright © 1995-1997 Roger E. Critchlow Jr.