LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-29-2007, 07:46 AM   #1
johnpaulodonnell
Member
 
Registered: Jun 2006
Location: Galway
Distribution: Suse 10.1
Posts: 114

Rep: Reputation: 15
my_var defined. How do I call $(my_var)_extension ?


Hi.

Within a bash script, I have a variable, stn_name, representing the name of a seismic station. I have a large number of these stations. Associated with each of these station names is a set of coordinates, also defined stn_name_coords

Within a for loop I'm looping over the station names and doing such and such. The basic structure is as follows:

stn="stn_name1 stn_name2 stn_name3 ....... stn_nameN"

stn_name1_coords="lat1 lon1"
stn_name2_coords="lat2 lon2"
.........................................
................etc....................
........................................


for i in $stn
do ........


prog "$(i)_coords" .... *** How is this done? ***

done


When I'm looping over the station names I need to pass each station's coordinates to a program that will calculate a value that I need, but I don't know how to call the 'stn_name_coord' variable correctly.

Any help would be much appreciated.
Thanks.
 
Old 01-29-2007, 08:13 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Code:
prog "${i}_coords" ...
 
Old 01-29-2007, 08:23 AM   #3
johnpaulodonnell
Member
 
Registered: Jun 2006
Location: Galway
Distribution: Suse 10.1
Posts: 114

Original Poster
Rep: Reputation: 15
Wrong type of brackets!

Thanks colucix
 
  


Reply


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
cfmakeraw not defined sharathkv Programming 1 12-07-2006 11:00 PM
where defined(__i386) is being defined?? syseeker Programming 1 06-27-2006 07:24 AM
What do you call your remote control? I call mine... RHLinuxGUY General 19 10-18-2004 07:23 AM
No Mountpoints defined Zvezda Linux - General 0 12-22-2001 12:54 PM


All times are GMT -5. The time now is 10:03 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration