I have a file df.txt in the following. In each line of df.txt, there are four place holders x1 ~ x4. Then I have another file param.txt, while each row has four values. I want to write a script, while for each loop, the first row in the param.txt file will replace x1~ x4 in all rows in the df.txt file. So if there are n rows in the param.txt file, there will be n df.txt files. After each loop, the filled df.txt file will be in a specific directory. How to realize this through a script? Thanks.

Are the fields to be replaced always in the same positions as shown in your sample? If so, the an easy approach would be to loop over both files putting the fields into arrays and use splice to do the replacement.