I'm trying to run the following script:
#!/bin/sh . ./test.prop for ((i=0; i<10;i++) do echo $F($i) done
The file it sources contains parameter assignments:
F1=20 F2=30 F3=40 . . .
The desired output of the script would be
10 20 30 40 . . .
What is the proper syntax for
$F($i)? or I just can't simply use it?
You should probably use
eval "echo \$F$i"
Eval is used to evaluate and then run a command, allowing you to dynamically generate the command. By escaping the first dollar symbol, it is used explicitly in the generated command, while note escaping the second dollar symbol allows us to expand its value into a number used to generate the variable name. So suppose that
$i contains the value "1", the generated command is
Hope this helps =)