LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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, 06: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, 10: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: 344Reputation: 344Reputation: 344Reputation: 344
Bash actually has arrays, no need to simulate them.
 
Old 10-29-2007, 09: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



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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

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
Open Source Consulting | Domain Registration