DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Writing Deskshell commands

Subsets

You can extract specific elements from a list by putting one or more element numbers after the variable name in brackets. Using the example in ``Variable substitutions'':

   $editors(2)
will have the value:
   xedit


NOTE: There must not be any spaces between the variable name and the opening bracket.

More than one subscript can be given. For example, the following:

   days=(mon tue wed thur fri sat sun)
   echo $days(3 1 3)
will produce:
   wed mon wed

Subscripts that are out of range are ignored, so the same result is obtained with:

   echo $days(3 0 1 8 3)

The element numbers may come from another variable or any other construct, so:

   $days($#days)
is permitted and has the value
   sun

Next topic: Function arguments
Previous topic: Variable substitutions

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 26 May 2005