I have a python program that I have parsed into the linux command line. It requires two inputs. The first input will always be the same and I want the second input to be anywhere from 1-1030.Is there a way I can get python to run that automatically in the command line and each time increase the second input by +1? I would like to do this so I do not have to manually type the second input 1030 times.
My command line looks something like this:
$ python ex_script.py -d (first input) -r (second input)
Advertisement
Answer
Just use for loops in bash.
for i in {1..1030} do python ex_script.py -d <the first input here> -r $i done
The loop will iterate through the numbers 1 to 1030. Then, you could put any command-line instructions inside the loop and use the variable $i, passing it as an argument for the instruction.
You could put it into a .sh file and make it executable using chmod +x
.
Then run it as an executable script from the terminal.