$ of $i

Is it possible to calculate $ of $i?

for example:

There is a script : double.bash
-------------
i = 1;

valueofi = $i
file1=$1
file2=$2
argument = $($i) >>>>>>? IS this possible?
--------------
I run it by: bash double.bash filename1 filename2

I was wondering if it is possible to do this operation the $($i) ?

Could you explain what you're actually trying to do, instead of the syntax you made up for it? There's quite probably a way to do what you want, but I can only guess what you're actually after.

If you want to get the value of a variable given its name, you can use the ${!VAR} syntax in bash and ksh:

$ ASDF="qwerty"
$ VARNAME="ASDF"
$ echo "${!VARNAME}"
qwerty

$

$1 gives the arguments while you call the file.

now replace 1 by i where i =1
=> $i => 1 but not the arguments...

=> SO I was thinking if there is something like $($i) = $(1) = argument1

That's still exactly what I showed you.

$ echo $0
-bash

$ VARNAME=0
$ echo "${!VARNAME}"
-bash

$

Interesting. The ${!VARNAME} syntax does not work on our ksh or ksh93 on Solaris. Throws a bad substitution error.

Doing it using eval works though with either shell:

#!/bin/bash

ASDF="qwerty"
VARNAME="ASDF"

# If ksh, below errors with:   "${!VARNAME}": bad substitution
echo ${!VARNAME}

# This works with either shell:
eval echo "\$${VARNAME}"

Output:
$ efs
qwerty
qwerty
$

Ooopss....
Thanks for both the solutions!