I am running a genetic algorithm for multiple seed values and for each run I want to put the seed value in the name of the output file. I have been able to do that using the following Bash script.
1 #!/bin/bash
2 # Multi-seed script
3
4 seed=0.01
5 for count in {1..100..1}
6 do echo "$seed"
7 ./nsga2r $seed < input_data/truss.in
8 $(mv all_pop.out all_pop_seed"$count".out)
9 seed=$(echo "$seed+0.01" | bc)
10 done
The script if very straight forward. Line-5 runs the loop for 100 seed values. Line-7 runs the program nsga2r for current seed value taking input values from file input_data/truss.in. Line-8 adds the current seed value to the name of the output file of current seed value. This yields the output as :
all_pop_seed1.out
all_pop_seed2.out
all_pop_seed3.out
...
all_pop_seed10.out
all_pop_seed11.out
...
all_pop_seed99.out
all_pop_seed100.out
BUT how do I name them like the following instead?
all_pop_seed001.out
all_pop_seed002.out
all_pop_seed003.out
...
all_pop_seed010.out
all_pop_seed011.out
...
all_pop_seed099.out
all_pop_seed100.out
Although this minor difference from my desired output filenames does not hinder my further analysis, still I would like to know.
3as003. do you see how you can formulate the question in a single line? reduce the problem to its minimal form.