Replace text in input file

I wish to replace values of specific parameters in an input file for batch runs of a java code. It's essentially a nested for-loop sorta like this:

valuearray1 contains values for param1
valuearray2 contains values for param2

for (all values in valuearray1)
go into specific position in "input.txt" (marked by say character pos1) and replace param1 with current value from valuearray1 for (all values in valuearray2)
go into specific position in "input.txt" (marked by say character pos2) and replace param2 with current value from valuearray2
run the simulation code
get next value from valuearray2
get next value from valuearray1DONE!

I'm new to scripting so any help from the experts would be deeply appreciated!

-Sam

Where do the arrays get their data from? Is it in a file or do you store it in the script?

What does "marked by character x" mean? Like find a line with the specified character at the beginning and only substitute on that particular line? Or all lines following that line? Or all lines with that marking?

Does input.txt need to change on every iteration or can the java program read it on standard input? I would suggest to keep a static file and run each java program on a temporary copy.

#!/bin/sh

valuearray1="foo bar baz"
valuearray2="ick y poo"

for v1 in $valuearray1; do
  for v2 in $valuearray2; do
    sed -e "/^pos1/s/param1/$v1/" -e "/^pos2/s/param2/$v2/" input.txt >/tmp/input.txt
    java suction /tmp/input.txt
  done
done

You've got it, the code works beautifully after some changes here and there. Thx!