0

Hi,

I am writing a shell script, and need help with a small piece of code.
It is as below:

CUST_1=filename
b=1
c=$CUST_$b
echo $c

I want the output from this as filename, whereas I get it as 1.
Please guide as if where am I going wrong in here.

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by iceman29
0

Weird, but it can be done.

CUST_1=filename
b=1
eval c=\$CUST_$b
echo $c

There may be easier ways to do what you mean, like using an array. But this works, and gets points for being 'clever'.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.