The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
awk computed variable names craig06y Shell Programming and Scripting 4 02-05-2008 01:50 PM
echo contents of differing variable names gefa Shell Programming and Scripting 2 05-24-2005 08:49 AM
KDE names gnerd What's on Your Mind? 1 07-18-2004 11:26 AM
Variable assignment for file names. jagannatha UNIX for Dummies Questions & Answers 2 05-29-2003 05:38 PM
Variable names Bab00shka Shell Programming and Scripting 4 08-15-2002 12:00 PM

Closed Thread
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
  #1 (permalink)  
Old 11-11-2005
Bab00shka Bab00shka is offline
Registered User
  
 

Join Date: Apr 2002
Location: Chesterfield, UK
Posts: 123
Variable names

Hi,

I have a variable v_iteration which can equal any 3 digit number eg 001 or 926

I would like to dynamically make a new variable name up using this 3 digit number

eg

v_another_variable_001=fred
v_another_variable_926=joe


The following are examples of what I have tried

v_another_variable_$v_iteration=fred
v_another_variable_"$v_iteration"=fred


and

eval v_another_variable_"$_viteration"=fred

all of which return the following error

v_another_variable_ : parameter not set

Can anyone help me with this please? I am using Korn Shell.

Many thanks
Helen
  #2 (permalink)  
Old 11-11-2005
vgersh99's Avatar
vgersh99 vgersh99 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,131

Code:
#!/bin/ksh

v_iteration=001

eval v_another_variable_${v_iteration}='fred'
echo "v_another_variable_${v_iteration} -> ${v_another_variable_001}"

v_iteration=926
eval v_another_variable_${v_iteration}='bob'
echo "v_another_variable_926 -> ${v_another_variable_926}"

  #3 (permalink)  
Old 11-11-2005
Bab00shka Bab00shka is offline
Registered User
  
 

Join Date: Apr 2002
Location: Chesterfield, UK
Posts: 123
Thanks vgersh

In my effort to simplify the problem, I think I got it out of context.

The actual line I'm getting the error on (and am still getting the error) is

eval v_another_variable_${v_iteration}="$v_another_variable_${v_iteration}""$v_different_variable_${v_ite ration}"

I am making an attempt to append the contects of v_different_variable_$(v_iteration} on to the contents of v_another_variable_${v_iteration}

Any further help would be greatly appreciated!

Many thanks
Helen
Closed Thread

Bookmarks

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 07:30 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