The Select expression is a bash extension application, especially for interactive use. You can select from a group of different values.
Select VaR in...; do
Break
Done
... Now $ VaR can be used ....
The following is an example:
#! /Bin/sh
Echo "What is your favorite OS? "
Select VaR in "Linux" "GNU Hurd" "Free BSD" "other"; do
Break
Done
Echo "you have selected $ Var"
The following is the result of running the script:
What is your favorite OS?
1) Linux
2) GNU Hurd
3) Free BSD
4) Other
#? 1
You have selected Linux
The for-loop expression is used to view a string list (strings are separated by spaces) and then assigned to a variable:
For VaR in...; do
....
Done
In the following example, ABC is printed to the screen:
#! /Bin/sh
For var in a B C; do
Echo "Var is $ Var"
Done
Output all files starting with test on the screen:
For VaR in $ (LS test *); do
Echo $ VaR
Done