Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers


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 !!

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 06-10-2012
Registered User
 
Join Date: Jun 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Data Double variable substitution


Code:
$ ABCel='abc@gmail.com'
$ XYZel='xyz@gmail.com'
$ MYel='my@yahoo.com'

$ echo $ABCel
abc@gmail.com
$ echo $XYZel
xyz@gmail.com
$ echo $MYel
my@yahoo.com


I tried 3 variations, but not getting the expected result:


Code:
$ for VAR in ABC XYZ; do echo -e "${VAR}el $MYel"; done
ABCel my@yahoo.com
XYZel my@yahoo.com



Code:
$ for VAR in ABC XYZ; do MAIL=${VAR}el; echo -e "$MAIL $MYel"; done
ABCel my@yahoo.com
XYZel my@yahoo.com



Code:
$ for VAR in ABC XYZ; do MAIL=${VAR}el; echo -e "${MAIL} $MYel"; done
ABCel my@yahoo.com
XYZel my@yahoo.com

Expecting Result:
---------------------

Code:
abc@gmail.com my@yahoo.com
xyz@gmail.com my@yahoo.com

What am I missing here?
Thanks

Last edited by Scrutinizer; 06-10-2012 at 02:55 PM.. Reason: code tags
Sponsored Links
    #2  
Old 06-10-2012
Registered User
 
Join Date: Aug 2009
Location: France
Posts: 294
Thanks: 12
Thanked 66 Times in 65 Posts
Try this: eval echo \$${VAR}el
Sponsored Links
Closed Thread

Tags
variable substituion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Using echo to print double quotes along with variable substitution sarbjit Shell Programming and Scripting 4 01-28-2010 03:11 AM
Sed variable substitution when variable constructed of a directory path alrinno Shell Programming and Scripting 2 07-11-2008 02:24 PM
double substitution pppswing Shell Programming and Scripting 1 07-03-2008 08:10 AM
Double Substitution variables in ksh xiamin Shell Programming and Scripting 19 05-23-2007 04:35 AM
double variable substitution asal_email2 UNIX for Dummies Questions & Answers 1 06-14-2005 12:35 AM



All times are GMT -4. The time now is 07:38 PM.