Reputation: 1
I have the following bash code:
for (( i=4; i<=$var; ))
do
temp=`echo $i`
done
I need to assign the command line argument stored in $4 to the variable temp which is not happening.
Upvotes: 0
Views: 258
Reputation: 123410
Given a variable i=4
you can get the value of $4
using ${!i}
:
set -- foo bar baz thisOne etc
i=4
echo "${!i}"
This prints the fourth positional parameter, thisOne
.
Upvotes: 1