I need to change the seed's value, the output (HA.xyz) and the namefile to generate 100 different files.

# MSA: H2O
seed 129472
tolerance 1.0
filetype xyz
output HA.xyz

Structure H2O.xyz
 inside cube
end structure

Structure .xyz
 inside cube
end structure

closed as unclear what you're asking by RomanPerekhrest, Anthon, Philippos, sebasth, Jeff Schaller Sep 26 '17 at 9:35

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Where is the variable namefile? Where is your program, and what is your exact question? Please read the tour, we are not a script-writing service. – Anthon Sep 26 '17 at 7:55
  • 1
    Where do you keep the 100 names and the seed values? And what does this have to do with make? – Kusalananda Sep 26 '17 at 7:55
  • i have a file with thousands of random numbers – Eduardo Mtz Sep 26 '17 at 7:57
  • The namefile is the same as the seed – Eduardo Mtz Sep 26 '17 at 8:00
  • 1
    What is the format of that file? Seed, followed by a filename, with a space inbetween? – Kusalananda Sep 26 '17 at 8:01
while read -r seed name; do
    sed -e "s/^seed.*/seed $seed/" \
        -e "s/^output.*/output $name/" template.txt >"${name%.*}-$seed.conf"
done <file.in

This will read a file called file.in. The format of that file should be

00000 filename.ext

(seed value in the first column, a space, and a filename)

The sed command will take the template from template.txt, a file formatted as in the question and generate new files.

The new files will have names like filename-00000.conf (using the filename, without filename extension, and seed from the file.in file).

The sed expressions simple look for lines in template.txt that start with either seed or output and inserts the appropriate values.

Not the answer you're looking for? Browse other questions tagged or ask your own question.