![]() |
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 |
| I need help with arrays in C Shell | domain | Shell Programming and Scripting | 5 | 11-19-2008 08:17 AM |
| how to use arrays in c shell | hgphsf | Shell Programming and Scripting | 6 | 12-14-2007 02:03 PM |
| Bourne-again shell | mrsamer | UNIX for Dummies Questions & Answers | 3 | 09-30-2006 02:42 AM |
| Bourne Shell scripting help | PoloRL185 | Shell Programming and Scripting | 1 | 05-13-2005 12:09 PM |
| bourne shell not working | gillbates | Shell Programming and Scripting | 6 | 06-17-2004 04:22 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Bourne Shell and Arrays
Hi everyone, first post here so please be gentle :-)
I normally likle to script in Bourne Shell simply for guarenteed compatibility across any system I might run across but this latest problem has me stumped. Arrays is a rather significant construct missing from sh and after finding a way to 'fudge' them using eval I thought I found the solution to my problem. However I cant seem to get it to work in all circumnstances. I wont go into all the details, I'll just give you a trivial example. x=0 eval DATA${x}="element$x" x=`expr $x + 1` eval DATA${x}="element$x" x=0 eval echo \$DATA$x x=`expr $x + 1` eval echo \$DATA$x This correct echos "element0" and "element1". However what I cannot get to work is using the eval within a test construct. What I would like to do is this: if [ "`eval echo \$DATA$x`" = "element0" ] then echo element 0 found fi but it just doesnt work. the eval works fiune standalone but withing back quotes it doesn't. I am obviously misunderstanding something as to how back quote execution, eval, or possibly both work. So I dont know even if its possible to do this at all. I've tried all sensible (and not so sensible) combinations of quotationa dn escaping to no avail. Any help appreciated. Sean Timmins |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|