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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
redirecting variable content to a file! lloowen Shell Programming and Scripting 2 05-24-2008 01:30 PM
how to delete content in a file (delete content only) kittusri9 Shell Programming and Scripting 5 05-15-2008 10:12 AM
how to store the first content of the folder in a variable?(Urgent) sunitachoudhury Shell Programming and Scripting 3 04-08-2008 12:11 AM
How to replace a variable content josephwong Shell Programming and Scripting 4 06-25-2006 08:18 PM
Compare the content of a variable with a string robdai UNIX for Dummies Questions & Answers 2 11-01-2005 03:29 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-26-2007
jaduks's Avatar
Registered User
 

Join Date: Aug 2007
Location: Assam,India
Posts: 145
Stumble this Post!
Content of Content of a variable!

I got a sample BASH script like this :

$ cat test
MYVAR=$1
DUMMY1="This is tricky"
DUMMY2=24
echo $[$MYVAR]


$ ./test DUMMY1
./test: line 5: This is tricky: syntax error in expression (error token is "is tricky")
**I was expecting the output as "This is tricky", ah! but no luck


**But this works fine for intergers, no issues :-)
$ ./test DUMMY2
24

Could anyone guide me how to get the string in DUMMY1(i.e "This is tricky") through MYVAR? Please
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 08-26-2007
Registered User
 

Join Date: Jul 2007
Location: india
Posts: 25
Stumble this Post!
Instead of echo $[$MYVAR], you can use : echo ${!MYVAR}...It will be working fine.
Reply With Quote
  #3 (permalink)  
Old 08-26-2007
jaduks's Avatar
Registered User
 

Join Date: Aug 2007
Location: Assam,India
Posts: 145
Stumble this Post!
Navojit, that worked for me :-) Thanks a lot
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 09:57 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0