Using multiple values for single variable in a loop
I have a small loop problem as below.
I have 3 different values to be used while running the same script -
Now I want to use these three variable values to be used for running the same command, like -
bin/java -s (run something with $var);
Now I want $var taking the value of var1, var2 and var3 each time it runs,
so can someone please tell me how do we achieve the above?
I tried doing -
for $1 $2 $3
while read a b c
<code assumed to have loop iteration>
done <<< $(command)
But it isnt working as expected... Would really appreciate your help on this.
Very simply, don't use separate variables. Whenever you have lists of related entries, you should use an array.
(This is of course assuming you're using bash or another advanced shell. Posix doesn't define arrays, so #!/bin/sh -style scripts shouldn't have them. )
Also, please use [code][/code] tags around your code and data, to preserve formatting and to improve readability.
|All times are GMT -5. The time now is 11:31 PM.|