Fork me on GitHub

Project Notes

#003 Select Menus

Getting multiple-choice input from a user in a bash script.


Bash scripts are great for automating system management tasks. They are made more useful and general if there’s a way for the user to change the behaviour. This is what command line parameters are usually for.

But sometimes it is best to get interactive input with a menu of options.

The select built-in function provides a very simple way to implement a menu.


The demonstrates a basic menu using select.

$ ./

This script demonstrates the basic select menu.

1) apple
2) orange
3) quit
select> 1
You picked apple (1)
select> 2
You picked orange (2)
select> 3
You picked quit (3)

Credits and References

About LCK#18 Bash
Project Source on GitHub Return to the Project Catalog

This page is a web-friendly rendering of my project notes shared in the LittleCodingKata GitHub repository.

LittleCodingKata is my collection of programming exercises, research and code toys broadly spanning things that relate to programming and software development (languages, frameworks and tools).

These range from the trivial to the complex and serious. Many are inspired by existing work and I'll note credits and references where applicable. The focus is quite scattered, as I variously work on things new and important in the moment, or go back to revisit things from the past.

This is primarily a personal collection for my own edification and learning, but anyone who stumbles by is welcome to borrow, steal or reference the work here. And if you spot errors or issues I'd really appreciate some feedback - create an issue, send me an email or even send a pull-request.