开发者

How to use variables in another shell script in a loop in my main script?

I already mentioned in my last question that I have a main method in script1 wh开发者_JAVA技巧ich has to run for each set of variables in script2.

I want to run the main script again and again for each set of variables (var1 to var8 since the main method utilises 8 variables to run) in script2.

How do I achieve this?


script1:

var1=(a b c)
...
var8=(98 545 4)
for (( i = 0 ; i < 3 ; i++ ))
do
  script2 ${var1[i]} ... ${var8[i]}
done

script2:

if [ $# -eq 9 ]; then  # $# is the total number of arguments.
    var1=$1
    ...
    var8=$8
fi
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜