The UNIX and Linux Forums  


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
Need help in resolving Compilation error jagan_kalluri UNIX for Dummies Questions & Answers 1 05-20-2008 03:45 PM
DNS not resolving Mr Pink UNIX for Advanced & Expert Users 9 05-17-2006 08:22 AM
Resolving port 8080 in DNS korfnz IP Networking 1 10-18-2004 07:42 PM
Resolving ip, detective work kymberm IP Networking 1 02-13-2003 05:29 PM
Resolving Aliases and Virtual IP's on a Host Scott Pullen UNIX for Advanced & Expert Users 1 12-20-2001 02:11 PM

 
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 07-20-2009
gio001 gio001 is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 70
Resolving Var to its contents

Hello everyone....
I am trying to dinamically create variable names and do resolution of this vars contents.
After that is done I want to use (via a function call) the var and its contents by referring to it via the variable name.
I am having a hard time achieving this .... can you help ?

Example:


Code:
#! /bin/ksh

_func2(){
emt=test1_$1
emc=test2_$1
   echo $emt
   echo $emc

emt=$emt"_EM"
emc=$emc"_EM"
   echo $emt
   echo $emc
}

Datenow=`date +%Y%m%d%H%M`
test1_x1=/dir1/test/FileOneOne_$Datenow
test1_x2=/dir1/test/FileOneTwo_$Datenow

test2_x1=/dir1/test/FileTwoOne_$Datenow
test2_x2=/dir1/test/FileTwoTwo_$Datenow

test1_x1_EM=/dir1/test/OneOne_$Datenow
test1_x2_EM=/dir1/test/OneTwo_$Datenow

test2_x1_EM=/dir1/test/TwoOne_$Datenow
test2_x2_EM=/dir1/test/TwoTwo_$Datenow

_func2  x1
_func2  x2


When I run this I get the following output, how can I get the variable to resolve to its content?


Code:
test1_x1
test2_x1
test1_x1_EM
test2_x1_EM
test1_x2
test2_x2
test1_x2_EM
test2_x2_EM


Last edited by vgersh99; 07-20-2009 at 03:37 PM.. Reason: code tags, PLEASE!
Bits Awarded / Charged to gio001 for this Post
Date User Comment Amount
07-20-2009 vgersh99 added code tags - charged 3K bits -3,000
 

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 06:10 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