LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

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

Rep: Reputation: 0
Question 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!
 
Old 10-28-2007, 11:08 PM   #2
macemoneta
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: 328Reputation: 328Reputation: 328Reputation: 328
Bash actually has arrays, no need to simulate them.
 
Old 10-29-2007, 10:28 PM   #3
vegas35
LQ Newbie
 
Registered: Oct 2007
Posts: 10

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


Reply

Tags
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 04:35 AM
SED and shell variables 3saul Linux - Software 4 12-29-2005 12:37 AM
Shell variables Milosevic Linux - Newbie 2 12-10-2005 11:32 PM
Setting Shell variables tmoorman Linux - Software 6 11-19-2003 04:41 PM
Shell Variables. ducka Programming 5 09-03-2003 06:38 PM


All times are GMT -5. The time now is 05:16 AM.

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