Bash scripting advanced variable help

1 reply [Last post]
Joined: 2011/11/02

Hey guys having trouble with a bash script if anyone can give me a nudge in the right direction it would be most appriciated


echo ${pos} # echos "$a"
eval char=${pos}
echo ${char} #echos "0"
char=1 #Set char variable to 1

This is where I get lost I need to set the new value of $char to the variable that is held in $pos which at this time is $a I tried these and many more

eval ${pos}=${char}
eval 'echo $pos'=${char}

It either doesnt work at all or it sets the $pos variable to the value of $char which is "1"
I need $pos variable to stay "$a" but the $a variable to take the value of the $char variable
I hope I have made it clear what I need, any information is very appriciated since I have tried to find it on the internet but not sure how to look it up. Thx for your time Cheers