Trying to figure out the best way to automate running a command that takes a lot of parameters and changing some of them. Current approach is this:
#!/bin/bash
# 5 more of these
VALUE=42
STUFF=12
CHARLIE=96
# Note that these are not sequential, just a bad example
PARAM[0]='--oneparameter=17'
PARAM[1]='--anotherparam=FOO'
PARAM[2]='--yetanotherparam=BAR'
PARAM[3]='--someparam4=314'
# the above continues for 15 parameters or so
# and then some ones like this one:
PARAM[16]="--someparam=astring${STUFF}.foo"
PARAM[20]="--someparam20=filename${VALUE}.foo"
Then I call the binary:
./mybinary ${PARAM[@]}
and all is well.
Then I change some parameter for the second run:
PARAM[1]='--anotherparam=BAR'
VALUE=84
# Here I need to include all lines that depends on VALUE
# for the parameter expansion to work
PARAM[20]="--someparam20=filename${VALUE}.foo"
./mybinary ${PARAM[@]}
This continues for 30 runs or so...
The above works but it's ugly and error-prone but I can't figure out a better way to do it! Any help is greatly appreciated!
Thanks.