Updated 2015-01-14 04:26:39 by RLE

Summary  edit

obtain the names of keys in an array

Synopsis  edit

array names arrayName ?mode? ?pattern?

See Also  edit


Description  edit

Returns a list containing the names of all of the elements in the array that match pattern. Mode may be one of -exact, -glob, or -regexp. If specified, mode designates which matching rules to use to match pattern against the names of the elements in the array. If not specified, mode defaults to -glob. See the documentation for string match for information on glob style matching, and the documentation for regexp for information on regexp matching. If pattern is omitted then the command returns all of the element names in the array. If there are no (matching) elements in the array, or if arrayName isn't the name of an array variable, then an empty string is returned.

To obtain the keys in alphabetical order:
foreach key [lsort [array names arr]] {...}