puzzle
Bill Suetholz
rrvvrr at mixcom.UUCP
Fri Nov 30 11:32:47 AEST 1990
I tried this shell script and it performs as requested...
-----------------------------CUT HERE -------------------------------------
#!/bin/sh
first_time="first_time"
second_time="second_time"
PREFIX="first second"
SUFFIX="time"
for WORDS in $PREFIX
do
eval ITERATION=\$${WORDS}_${SUFFIX}
echo "Iteration is $ITERATION"
done
exit 0
----------------------------------------------------------------------------
A few things to note:
1) the line with the eval was supposed to have WORDS not PREFIX in it.
2) use eval to get shell to evaluate the line twice;
once for $WORDS and $SUFFIX and once for $first_time or $second_time.
Bill Suetholz (bills at mixcom.UUNET)
More information about the Comp.unix.internals
mailing list