select: Accept keyboard input

The select construct allows the easy generation of
menus. It has almost the same syntax as the for command.

Syntax
select name [in words ...]; do commands; done
The list of words following in is expanded, generating a list
of items. The set of expanded words is printed on the standard error output
stream, each preceded by a number.

If the `in words? is omitted, the positional parameters
are printed, as if `in "$@"? had been specifed. The PS3
prompt is then displayed and a line is read from the standard input. If the
line consists of a number corresponding to one of the displayed words, then
the value of name is set to that word. If the line is empty, the
words and prompt are displayed again. If EOF is read, the select
command completes. Any other value read causes name to be set to
null. The line read is saved in the variable REPLY.

The commands are executed after each selection until a break
or return command is executed, at which point the select
command completes.

Here is an example that allows the user to pick a filename from the current
directory, and displays the name and index of the file selected.
select fname in *;
do
echo you picked $fname ($REPLY)
break;
done

((...))
(( expression ))

If the value of the expression is non-zero, the return status is 0; otherwise
the return status is 1. This is exactly equivalent to
let "expression"
The truly successful businessman is essentially a dissenter, a rebel who is seldom if ever satisfied with the status quo" -
J. Paul Getty
Tags
Comments
Write the first comment
Leave a trace
Name *
Email *
Website
Anti SPAM * Code (7 + 7) =
Leave me a comment *
 
All comments are subject to editorial review
Post being viewed right now
Item date: 07.06.2010
Views: 560
Item date: 28.06.2010
Views: 1535
Item date: 30.09.2009
Views: 412
Item date: 10.04.2009
Views: 1584
Item date: 01.02.2009
Views: 338
Item date: 12.12.2009
Views: 2107
Item date: 16.06.2009
Views: 1332
Item date: 20.07.2009
Views: 957
Item date: 27.09.2009
Views: 963
Item date: 05.02.2009
Views: 996