m********e 发帖数: 23 | 1 遇到一个写脚本的问题,下面注释是我的问题,哪位大侠指点一下?谢谢!
TESTS="a b"
RUNa='date'
RUNb='who'
for i in $TESTS
do
run="RUN$i"
#here I want to run the command stored in $run, how to do it?
#cannot use ${$run}
done | t*****g 发帖数: 1275 | 2
command $run
【在 m********e 的大作中提到】 : 遇到一个写脚本的问题,下面注释是我的问题,哪位大侠指点一下?谢谢! : TESTS="a b" : RUNa='date' : RUNb='who' : for i in $TESTS : do : run="RUN$i" : #here I want to run the command stored in $run, how to do it? : #cannot use ${$run} : done
| c***g 发帖数: 30 | 3 This should work.
TESTS="a b"
RUNa='date'
RUNb='who'
for i in $TESTS
do
run="RUN$i"
eval comm=\$"$run"
$comm
done |
|