LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Need help - combining variables in shell (https://www.linuxquestions.org/questions/programming-9/need-help-combining-variables-in-shell-595323/)

vegas35 10-28-2007 06:17 PM

Need help - combining variables in shell
 
Greetings!

In shell (bash), I'm trying to interpolate a variable into part of another variable's name. I don't know if that made any sense, but here's what I'm doing:

Code:

#!/bin/sh
r1=35; r2=32; r3=36
for i in $(seq 3)
do
  echo ${r$i}
done

I'm looking for the output to be the values of $r1, $r2, and $r3. Is this possible?

Thanks for any help!

macemoneta 10-28-2007 10:08 PM

Bash actually has arrays, no need to simulate them.

vegas35 10-29-2007 09:28 PM

Quote:

Originally Posted by macemoneta (Post 2940424)
Bash actually has arrays, no need to simulate them.

Der! Imadork. Thanks.


All times are GMT -5. The time now is 08:25 AM.