![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| How to interpret TOP | dj_jay_smith | UNIX for Dummies Questions & Answers | 7 | 05-23-2009 12:22 PM |
| Please interpret. | supacow | UNIX for Dummies Questions & Answers | 1 | 05-30-2008 03:11 AM |
| How Do We Interpret This ? | dummy_needhelp | Shell Programming and Scripting | 2 | 10-31-2007 02:07 PM |
| Riddle - solve it if you can | numstr | Shell Programming and Scripting | 1 | 08-15-2007 12:52 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread |
Rating:
|
Display Modes |
|
|
|
||||
|
Ksh riddle: interpret variable two times?
exam is a ksh script. In command line I enter: exam 3 param_2 param_3 param_4.
In exam how can I get the value of the parameter which position is specified by the first argument. Simply doing this DOES NOT work: offset=$1 value=$$offset can you figure out any possible way to interpret a variable two times |
|
||||
|
I'd like to correct: last one is not the same!
I've tryed it: Code:
bash-845:/home/dca0701/develop/src> nn=aa bash-846:/home/dca0701/develop/src> aa=final bash-851:/home/dca0701/develop/src> eval dn=\$$nn bash-852:/home/dca0701/develop/src> echo $dn final bash-853:/home/dca0701/develop/src> eval dn=$"$nn"; echo $dn aa First time by 'eval' the $nn should be substituted for 'aa' and '"' should be remuved (as I understand!). So result should be Code:
dn=$aa ------------------------- Ok, I've get it! It should be little bit different: Code:
eval dn="$"$nn; echo $dn So: the 'eval' do NOT evaluates value in double quotations or after backslash, but removes that quotations and backslashes! |
|
||||
|
The details
>So: the 'eval' do NOT evaluates value in double quotations or after backslash, but removes that quotations and backslashes!
Not exactly. Remember, the shell parses the entire line one time before "eval" gets to interpret it. Walking through: The original line looks like this: Code:
eval dn="$"$nn; echo $dn Code:
eval dn=$aa; echo final Also note that "$" evaluates to a literal dollar sign, because there is no way the shell can construe it as a variable indicator further details on my wiki... Last edited by vbe; 04-29-2009 at 04:18 AM.. Reason: Removed faulty URL (forum conformance...) |
![]() |
| Bookmarks |
| Tags |
| bash, bash eval, eval |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|