From: contracer on
Hi,
Can you help me with evaluating variables ?

>> cat g5

#!/bin/ksh
descr940="DataStaging System"

for INT in 940
do
echo $descr$INT
done


>> ./g5
940

(I need 'DataStaging System' output)
From: Janis Papanagnou on
contracer schrieb:
> Hi,
> Can you help me with evaluating variables ?
>
>>> cat g5
>
> #!/bin/ksh
> descr940="DataStaging System"
>
> for INT in 940
> do
> echo $descr$INT

eval echo \$descr$INT

> done
>
>
>>> ./g5
> 940
>
> (I need 'DataStaging System' output)

See above.

Janis
From: contracer on
On 9 ago, 12:08, Janis Papanagnou <janis_papanag...(a)hotmail.com>
wrote:
> contracer schrieb:
>
> > Hi,
> > Can you help me with evaluating variables ?
>
> >>> cat g5
>
> > #!/bin/ksh
> > descr940="DataStaging System"
>
> > for INT in 940
> > do
> > echo $descr$INT
>
> eval echo \$descr$INT
>
> > done
>
> >>>  ./g5
> > 940
>
> > (I need 'DataStaging System' output)
>
> See above.
>
> Janis

Thanks so much !
Regards.
From: Ed Morton on
On Aug 9, 10:11 am, contracer <contrace...(a)gmail.com> wrote:
> On 9 ago, 12:08, Janis Papanagnou <janis_papanag...(a)hotmail.com>
> wrote:
>
>
>
>
>
> > contracer schrieb:
>
> > > Hi,
> > > Can you help me with evaluating variables ?
>
> > >>> cat g5
>
> > > #!/bin/ksh
> > > descr940="DataStaging System"
>
> > > for INT in 940
> > > do
> > > echo $descr$INT
>
> > eval echo \$descr$INT
>
> > > done
>
> > >>>  ./g5
> > > 940
>
> > > (I need 'DataStaging System' output)
>
> > See above.
>
> > Janis
>
> Thanks so much !
> Regards.- Hide quoted text -
>
> - Show quoted text -

Why are you doing that though? If you REALLY wanted a script to do
that then you should use awk or similar:

$ cat ./g5
awk 'BEGIN{
descr[940]="DataStaging System"
for (INT in descr) {
print descr[INT]
}
exit
}'
$ ./g5
DataStaging System

Regards,

Ed.