|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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.comCode:
$ for VAR in ABC XYZ; do MAIL=${VAR}el; echo -e "$MAIL $MYel"; done
ABCel my@yahoo.com
XYZel my@yahoo.comCode:
$ for VAR in ABC XYZ; do MAIL=${VAR}el; echo -e "${MAIL} $MYel"; done
ABCel my@yahoo.com
XYZel my@yahoo.comExpecting 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
|
|||
|
|||
|
Try this:
eval echo \$${VAR}el
|
| Sponsored Links | ||
|
![]() |
| Tags |
| variable substituion |
| Thread Tools | Search this Thread |
| 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 |
|
|