[Techtalk] using variables as part of variable name
Dennis Wheeler
dennisw at vidiator.com
Fri May 14 16:54:43 EST 2004
Can I use a variable as part of a variable name in bash?
I'm not sure how best to describe it.
In other words I've got something like this:
src_da=foo1
src_bi=bar1
tgt_da=foo2
tgt_bi=bar2
cp $src_da $tgt_da
cp $src_bi $tgt_bi
and since I have a lot, I'd like to do something like:
for var in da fe gu vi
do
cp $src_$var $tgt_$var
done
Sorry if I'm posting this to the wrong list -- if someone moves this to
another list can you please cc me the replys?
Thanks
-- D
More information about the Techtalk
mailing list