Reputation: 51
I have a variable $x
that has a value of a position of an argument to the script (say 8). I need to capture the value in the 8th argument (say 1) into another variable y
and be able to use that as variable $y
($1) to refer to a column in a file.
Upvotes: 0
Views: 30
Reputation: 42999
You can use the indirect reference ${!var}
to do this:
set one two three four five six seven eight
x=8
y=${!x}
echo $y
You get this output:
eight
Upvotes: 1