Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 10-28-2007, 06:17 PM   #1
LQ Newbie
Registered: Oct 2007
Posts: 10

Rep: Reputation: 0
Question Need help - combining variables in shell


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:

r1=35; r2=32; r3=36
for i in $(seq 3)
  echo ${r$i}
I'm looking for the output to be the values of $r1, $r2, and $r3. Is this possible?

Thanks for any help!
Old 10-28-2007, 10:08 PM   #2
Senior Member
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
Bash actually has arrays, no need to simulate them.
Old 10-29-2007, 09:28 PM   #3
LQ Newbie
Registered: Oct 2007
Posts: 10

Original Poster
Rep: Reputation: 0
Originally Posted by macemoneta View Post
Bash actually has arrays, no need to simulate them.
Der! Imadork. Thanks.


bash, shell script

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script variables Fredde87 Linux - Newbie 13 11-01-2006 03:35 AM
SED and shell variables 3saul Linux - Software 4 12-28-2005 11:37 PM
Shell variables Milosevic Linux - Newbie 2 12-10-2005 10:32 PM
Setting Shell variables tmoorman Linux - Software 6 11-19-2003 03:41 PM
Shell Variables. ducka Programming 5 09-03-2003 05:38 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:37 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration