select varname in opt1 opt2...optN
do
case $varname in
opt1) command1;;
opt2) command2;;
optN) commandN;;
esac
done
Looking at this skeleton for a select statement, I am baffled as to what exactly "in" does. Does it pass a reference off from the first variable to the second?
It is part of the select syntax and it denotes the list of possibilities for the select statement. In this case there are two options (it is similar to how "in" in a for statement works)
in is a reserved word that have a special meaning to shell.
Below are few examples of compound commands where in is used:
for name [ [ in [ word ... ] ] ; ] do list ; done
select name [ in word ] ; do list ; done
case word in [ [(] pattern [ | pattern ] ... ) list ;; ] ... esac
In first 2 examples, words following in is expanded, generating a list of items.
In case command, first word is expanded and matched against pattern.