Re: [ILUG] Bourne[-again] shell

From: Lars Hecking (lhecking at domain nmrc.ucc.ie)
Date: Thu 14 Oct 1999 - 16:42:34 IST


Peter Flynn writes:
> 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

 "${SURNAME}${COUNTER}" maybe?

> 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?
 



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