LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 09-19-2006, 01:15 PM   #1
mr_scary
Member
 
Registered: Aug 2006
Posts: 39

Rep: Reputation: 15
sh or bash: composite variables


Hi, using sh or bash I have 2 variables defined:

host=master
master_IP=100

How can I echo the value of master_IP in terms of the the variable host?

I thought:

echo "$"$host"_IP"

would give me "100".

But it does not work. Anyone?

Peter
 
Old 09-19-2006, 01:50 PM   #2
spirit receiver
Member
 
Registered: May 2006
Location: Frankfurt, Germany
Distribution: SUSE 10.2
Posts: 424

Rep: Reputation: 33
Quote:
Originally Posted by mr_scary
Anyone?
Yes, me !!
Code:
ada@barnabas:~> eval "echo \$${host}_IP"
100
 
Old 09-19-2006, 02:13 PM   #3
mr_scary
Member
 
Registered: Aug 2006
Posts: 39

Original Poster
Rep: Reputation: 15
Very nice. Thank you.
 
  


Reply



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
Environment variables for bash htarko Programming 1 09-13-2006 03:57 PM
bash variables pfaendtner Linux - Newbie 4 11-23-2004 01:00 PM
variables in bash haddad Linux - General 6 09-22-2004 05:29 PM
Variables in bash tcaptain Programming 1 03-03-2003 02:07 PM
Bash variables pk21 Programming 2 01-09-2003 03:31 PM

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

All times are GMT -5. The time now is 02:08 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