OSF DCE Administration Guide--Core Components

OSF DCE Administration Guide—Core Components
2.8 Operating on Lists
Lists provide convenient ways to operate on collections of things such as sets of
principals, group members, or other objects. Lists are collections of objects entered by
you or returned from commands. We’ve already seen lists in previous examples in this
chapter; they’re any number of elements separated by spaces, tabs, or newlines. Usually,
a list is enclosed in braces.
All of the following are examples of lists:
{n_long l_jones p_sawyer d_witt m_dougherty s_preska}
{{/.:/hosts} {/.:/subsys}}
The DCE control program relies on lists to group elements so they can be correctly
parsed by the dcecp command interpreter. For example, the set command takes two
arguments:
set varName value
The following set command can’t be correctly parsed because dcecp detects a third
argument:
dcecp> set a John Hunter
Error: wrong # args: should be "set varName ?newValue?"
dcecp>
Use braces, quotes, or backslashes to create a valid list, as follows:
dcecp> set a {John Hunter}
John Hunter
dcecp> set a "John Hunter"
John Hunter
dcecp> set a John\ Hunter
John Hunter
dcecp>
The commands that operate on lists provide convenient ways to evaluate, select, and act
on individual elements or groups of elements in a list. The DCE control program
provides a comprehensive set of commands that let you create, modify, search, sort, and
convert to and from lists.
For example, the following script returns the last element in a list. The llength command
returns the number of elements in the list. Our list has four elements so llength returns 4.
The dcecp program numbers the elements from left to right starting with 0 (zero) so our
list with three elements has elements numbered 0, 1, 2, and 3. The value of variable c is
set to the number of the last element in the list (3). Finally the lindex command returns
element 2 (f).
2 16 Tandem Computers Incorporated 124243