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
redirecting variable content to a file! lloowen Shell Programming and Scripting 2 05-24-2008 04:30 PM
how to delete content in a file (delete content only) kittusri9 Shell Programming and Scripting 5 05-15-2008 01:12 PM
how to store the first content of the folder in a variable?(Urgent) sunitachoudhury Shell Programming and Scripting 3 04-08-2008 03:11 AM
How to replace a variable content josephwong Shell Programming and Scripting 4 06-25-2006 11:18 PM
Compare the content of a variable with a string robdai UNIX for Dummies Questions & Answers 2 11-01-2005 07:29 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-26-2007
jaduks's Avatar
jaduks jaduks is offline
Registered User
  
 

Join Date: Aug 2007
Location: Assam,India
Posts: 166
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
  #2 (permalink)  
Old 08-27-2007
navojit dutta navojit dutta is offline
Registered User
  
 

Join Date: Jul 2007
Location: Singapore
Posts: 32
Instead of echo $[$MYVAR], you can use : echo ${!MYVAR}...It will be working fine.
  #3 (permalink)  
Old 08-27-2007
jaduks's Avatar
jaduks jaduks is offline
Registered User
  
 

Join Date: Aug 2007
Location: Assam,India
Posts: 166
Navojit, that worked for me :-) Thanks a lot
Sponsored Links
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 06:21 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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