Results 1 to 2 of 2
I can't seem to find the correct syntax here. So I know how to do a for loop but how do I do an if statement in there or a ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 06-01-2012 #1
- Join Date
- Jun 2004
For and While loops via command line
for i in `seq 4`; do xcli.py fc_port_reset fc_port=1:fc_port:4:$i; done
However what if I want to make that 4 a variable and go all the way to 9? How do I do multiple variables as well as make a statement that says don't go past 9. I know logically I would do the following. But how would I express them in a command line loop?
int i = 1;
while x < 10; do xcli.py fc_port_reset fc_port=1:fc_port:i;if i < 5 i++ else i=1; x++; done
Any help would be appreciated.
- 06-02-2012 #2
- Join Date
- May 2011
I don't understand where an if is necessary, at least based upon what you say you want. if you want to go to 9, and not go past 9, then just do `seq 1 9`.
or if you want to make it a variable:
for i in `seq 1 $x`; do
but if you don't use $x again elsewhere, why do you want it to be a variable?
perhaps you should spell out exactly what you want your script to do.