select

Official Description

Produces a menu of words preceded by numbers.

Syntax

select identifier [in word...] ;do list ;done

Options

None

Oddities

Writes the menu to stderr.

Example

$ select item in b*          # Set up menu containing filenames
> do
> print $item                # Print selected filenames
> done
1) buzz
2) buzz1
3) buzz10
4) buzz2
5) buzz3
6) buzz4
#? 2                         # Choose item # 2
buzz1
#? 6                         # Choose item # 6
buzz4
#? 8                         # Ignores non-existent items

#?                           # Ctrl+D exits

$ print $PS3
#?                           # Prompts with PS3 variable contents (default #?)
$
				

Get Korn Shell Programming by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.