[ILUG] Bourne[-again] shell

From: Peter Flynn (pflynn at domain imbolc.ucc.ie)
Date: Thu 14 Oct 1999 - 16:28:24 IST


How's your shell? I have a script with variables

SURNAME1=foo
SURNAME2=bar
etc
SURNAME9=blort

and I want to reference these in a loop. My bash is rusty,
to say the least, and I don't do Perl.

while [ something]; do

COUNTER=(some function which increments the counter)

do something with ${SURNAME$COUNTER}
                  ^^^^^^^^^^^^^^^^^^ This is causing an error

done

The error says "bad substitution" but I can't see why. Or is
there something non-obvious needs to be done to the $COUNTER
to force it to evaluate and catenate with the string SURNAME?

///Peter



This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:04:44 GMT