Use Bash Binding Function:
#!/bin/bash n=3 echo ${!n}
Running this file:
$ ./ind apple banana cantaloupe dates
It produces:
cantaloupe
Edit:
You can also slice an array:
echo ${@:$n:1}
but not array indices:
echo ${@[n]}
Dennis Williamson Sep 30 '09 at 15:26 2009-09-30 15:26
source share