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
eval a variable that has a . ttshell Shell Programming and Scripting 3 06-11-2007 11:44 AM
using eval w/ echo wxornot Shell Programming and Scripting 2 01-17-2006 07:16 AM
using eval with set, wc, and expr wxornot Shell Programming and Scripting 2 01-08-2006 01:42 PM
use of eval n grep abhi UNIX for Dummies Questions & Answers 3 02-17-2005 07:38 AM
Suse 7.1 Eval (where is it) amucci UNIX for Dummies Questions & Answers 3 08-04-2001 03:27 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 05-31-2007
Registered User
 

Join Date: May 2007
Posts: 10
How to escape * in string when using eval

Hi

I am implementing array sort of functionality in shell script. I am using a variable1 , variable2 ...... to store temporary values. Now a counter is keeping track of it. For example count=8, variable8="mul * prod". When I try to echo $(variable$count), it replaces * by list of files in current directory.

Like :
set -x
z=9
variable9="kjhgfj * kdufhkjd"
Result=`eval echo '$'variable$z`

Is their any way by which I can echo value for special case like these where variable has a '*' in it ?


Regards,
Hanumanth
Reply With Quote
Forum Sponsor
  #2  
Old 05-31-2007
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,683
Code:
set -f
z=9
variable9="kjhgfj * kdufhkjd"
Result=`eval echo '$'variable$z`
Reply With Quote
  #3  
Old 05-31-2007
Registered User
 

Join Date: May 2007
Posts: 10
Thanks

Hi ... thanks for solution ... can you pls let me know wt is the meaning of
set -f
Reply With Quote
  #4  
Old 05-31-2007
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,683
Quote:
Originally Posted by Chandu2u
Hi ... thanks for solution ... can you pls let me know wt is the meaning of
set -f
Care to look at the man page of sh ? Search for set under BASH BUILTIN COMMANDS
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 04:33 AM.


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

Content Relevant URLs by vBSEO 3.2.0