SUMMARY

From: Ira Childress (irac@nis.comdata.com)
Date: Mon Nov 25 1996 - 15:09:25 CST


Thanks to:

stephen Harris <sweh@mpn.com>
harest@chou.CANR.Hydro.Qc.Ca (Claude Charest)
peter.allan@aeat.co.uk (Peter M Allan)

I wrote:

> Does anyone know how to setup arrays in bourne scripts? i.e., name(n)=abc
> name(n+1)=def, name(n+2)=ghi,....

Basically, the answer was, "no, not in bourne shells - try ksh or csh"

Not willing to accept that as a solution, I did some more "playing" with
the script. Here's a way to use arrays in bourne:

        #!/bin/sh
        n=1
        while [ $n -lt 5 ] ; do
           eval name$n=$n
           n=`expr $n + 1`
        done
        n=1
        while [ $n -lt 5 ] ; do
                var="echo \$name$n"
                eval $var
           n=`expr $n + 1`
        done

I haven't tried it in every conceivable situation, but from initial testing
it appears to work.

Ira.

                                . .
                                \\ //
                                 \\^ ^//
                                 ( o o )
                             oOOo __O__ oOOo
********************************************************************************
* Ira Childress * Integrated Systems Solutions Corporation *
* Systems Manager Integrator * An IBM Subsidiary *
* ISSC/Comdata * *
* Off 615/370-7662 ********************************************
* FAX 615/371-3167 * *
* irac@comdata.com * Comdata Corporation *
* Ira.Childress@nashville.com * Transportation/Finance/Gaming *
********************************************************************************
* There are two major products to come out of Berkeley: LSD and UNIX. *
* We do not believe this to be a coincidence. *
********************************************************************************



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:11:16 CDT