The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
create a new environment variable?? pbsrinivas UNIX for Dummies Questions & Answers 1 10-22-2007 08:42 AM
How do one evaulate a variable's value if it is number or not suman_jakkula Shell Programming and Scripting 1 04-20-2007 01:06 AM
Create Variable for a PATH mmignot Shell Programming and Scripting 2 11-06-2006 03:09 PM
How to create md5 Hash variable? cstovall Shell Programming and Scripting 1 02-05-2006 07:03 PM
Cut a Variable into sub variables based on a delimiter jingi1234 UNIX for Dummies Questions & Answers 6 05-06-2005 10:41 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 11-01-2007
benefactr benefactr is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 71
create variable name based on another variable's value

Hello,
I am needing to create a variable and assign it a value based on the value of a previosly defined variable... I am using KSH..

Example:
VAR1=COMPUTER1
I need another variable like ${VAR1}_FLAG="Y", so it would actually be COMPUTER1_FLAG="Y".

I will be looping through many values in a while loop and I need to keep track if I have already processed a value already. So my data may look like this:

COMPUTER1
COMPUTER2
COMPUTER3
COMPUTER1
COMPUTER3

Initially the value of my second variable I am attempting to create would be N, if it ever gets turned to Y because it hit a specific condition then I need to know that later on after I have looped through the values. I will go through the values again in another while loop to see which ones are Y now so then I would need to do this:
If [ ${VAR1}_FLAG = "Y" ]
then
... do stuff
fi



Hope I have explained enough detail... Thanks for any help.
 

Bookmarks

Tags
bash, bash eval, eval

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:53 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0