I'm working on a script that has an array of around 10 elements. All I have to do is that the script will accept user input of minimum 0 elements and maximum 10 elements (of the array) and it will execute whatever the corresponding array element says.
Example
Array -
array0=( [1]=echo "Foo" [2]=export CCACHE=true [3]=export FOO_FLAG=true [4]=unset BAR_FLAG )
Then the script will read inputs like -
read -a array0
And then something like -
for i in ${array0[@]} do access each element as $i. . . done
The output should look something like -
Type the elements - 1 4 2 Foo *unset BAR_FLAG *export CCACHE=true*
But i'm not able to do it unfortunately. There must be some mistake in the for/do loop.
If anybody can help...