how generate and substitute files with sed [closed]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
-1
down vote

favorite












I need some help changing 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
number
inside cube
end structure

Structure .xyz
number
inside cube
end structure









share|improve this question















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














up vote
-1
down vote

favorite












I need some help changing 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
number
inside cube
end structure

Structure .xyz
number
inside cube
end structure









share|improve this question















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












up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I need some help changing 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
number
inside cube
end structure

Structure .xyz
number
inside cube
end structure









share|improve this question















I need some help changing 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
number
inside cube
end structure

Structure .xyz
number
inside cube
end structure






sed variable-substitution






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 21 at 22:37









Rui F Ribeiro

36.4k1271116




36.4k1271116










asked Sep 26 '17 at 7:51









Eduardo Mtz

1




1




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.






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
















  • 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















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




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




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





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




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




The namefile is the same as the seed
– Eduardo Mtz
Sep 26 '17 at 8:00




1




1




What is the format of that file? Seed, followed by a filename, with a space inbetween?
– Kusalananda
Sep 26 '17 at 8:01




What is the format of that file? Seed, followed by a filename, with a space inbetween?
– Kusalananda
Sep 26 '17 at 8:01










1 Answer
1






active

oldest

votes

















up vote
2
down vote













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.






share|improve this answer



























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote













    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.






    share|improve this answer
























      up vote
      2
      down vote













      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.






      share|improve this answer






















        up vote
        2
        down vote










        up vote
        2
        down vote









        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.






        share|improve this answer












        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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Sep 26 '17 at 8:05









        Kusalananda

        106k14209327




        106k14209327












            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Displaying single band from multi-band raster using QGIS

            How many registers does an x86_64 CPU actually have?