diff --git a/pages/linux/select.md b/pages/linux/select.md new file mode 100644 index 000000000..ed33ebf79 --- /dev/null +++ b/pages/linux/select.md @@ -0,0 +1,16 @@ +# select + +> Bash builtin construct for creating menus. +> More information: . + +- Create a menu out of individual words: + +`select {{word}} in {{apple}} {{orange}} {{pear}} {{banana}}; do echo ${{word}}; done` + +- Create a menu for picking a file or folder from the current directory: + +`select {{file}} in *; do echo ${{file}}; done` + +- Create a menu from a Bash array: + +`{{fruits}}=({{apple}} {{orange}} {{pear}} {{banana}}); select {{word}} in ${{{fruits}}[@]}; do echo ${{word}}; done`