Shell script variable names created dynamically

Hi,

I'm trying to use a config file to define frequencies for checking log files. If the config file contains a frequency it will be used else a default value. The format of the config file (and hence the environment variable) is
FREQ_log_logname=value

A test shell script as below:

FREQ_log_aaa="DAILY"
FREQ_log_bbb="WEEKLY"
FREQ_log_ccc="DAILY"
for i in aaa bbb ccc
do
logfreq="$FREQ_log_$i"
echo "$logfreq";
done

outputs:

aaa
bbb
ccc

rather than the desired:

DAILY
WEEKLY
DAILY

I've spent the last hour trying eval but get the same or bad substitution errors. Does anybody know how to do this ? Thanks.

Try this change in your code...

...
eval logfreq="\$FREQ_log_$i"
...

PS : Use code tags!

--ahamed

Thanks ahamed ! Hadn't realised the first $ would need escaping. Sorry about the code tags, this is my first post on this site. Thanks again.