The select Statement (pdksh)
You use the select statement to generate a menu list if you are writing a shell program that expects input from the user online. The format of the select statement is as follows:
select item in itemlistdo StatementsDone
itemlist is optional. If it isn’t provided, the system iterates through the item entries one at a time. If itemlist is provided, however, the system iterates for each entry in itemlist and the current value of itemlist is assigned to item for each iteration, which then can be used as part of the statements being executed.
If you want to write a menu that gives the user a choice of picking a Continue or a Finish, you can write the following shell program:
#!/bin/kshselect item in Continue Finish ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access