I have 3 strings:
p001="57 59 13 30 96 45 24 71 33 15 40"
p002="57 7 13 11 80 44 47 50 84 86 64"
p003="57 7 13 11 50 44 42 50 84 86 64"
And based on the mcount (001,002, or 003)
, I want ptemp to be replaced. But I don't know how to "dynamically" create a new variable...
for mcount in {1..3}; do
pad_m=`printf "%03d" $mcount`
sed "s|PTEMP|p{pad_m}|; s|MTEMP|'${pad_m}'| " ./template.sh > .model.sh
This leads to error.
How can I do this?
Excerpt of template.sh
```
mnum=MTEMP
for pvar in PTEMP; do #Cycles through parameter files
pad_p=`printf "%03d" $pvar`
for svar in sq1 sq99; do
state_file=${mnum}/${svar}
./model.exe ${state_file}
done
done
```