Jump to content

variables within variables [solved]


Recommended Posts

hello,

 

I have a little problem. I have a file which looks like this:

 

NAMEA 12

NAMEB 53

NAMEC 10

NAMED 8

 

I process this using a little sed and awk to produce:

 

export NAMEA=12

 

which is run in the script using ` (aka funny quotes)

 

This sets up my variables nicely, now in the script i don't know what each od the variables will be called so i do a little for loop and reprocess the file i.e.:

 

for variable $(cat file | awk ' { print $1 } ')
do
 echo ${variable}
 echo $`echo ${variable}`
done

 

What i would like to do is the second line, i want to be able to set up a variable:

 

NAMEA=12

 

then loop through and echo NAMEA without knowing what it is called if that makes sense.

Edited by Apoc
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...