I want to retrieve the n-th parameter of $@ (the list of command line parameters passed to the script), where n is stored in a variable.
I tried ${$n}.
For example, I want to get the 2nd command line parameter of an invocation:
./my_script.sh alpha beta gamma
And the index should not be explicit but stored in a variable n.
Sourcecode:
n=2
echo ${$n}
I would expect the output to be "beta", but I get the error:
./my_script.sh: line 2: ${$n}: bad substitution
What am I doing wrong?