Answer the question
In order to leave comments, you need to log in
How to execute a command from a variable, for #!/bin/sh (not bash)?
[email protected] ~ $ komand7="echo 555"; for i in 1 2 3 4 5 6 7 8 9; do a="\$komand$i"; $a; done
$_komand1: команда не найдена
$_komand2: команда не найдена
$_komand3: команда не найдена
$_komand4: команда не найдена
$_komand5: команда не найдена
$_komand6: команда не найдена
$_komand7: команда не найдена
$_komand8: команда не найдена
$_komand9: команда не найдена
[email protected] ~ $ $_komand7
555
[email protected] ~ $
komand7="echo 555";komand9="ls -l"; for i in 1 2 3 4 5 6 7 8 9; do a="\$komand$i";echo $i; eval $a; done
Answer the question
In order to leave comments, you need to log in
komand7="echo 555"
for i in 1 2 3 4 5 6 7 8 9; do
a="komand$i"
${!a}
done
ideone.com/ShIYWg
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question