how generate and substitute files with sed [closed]
Clash 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
sed variable-substitution
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.
 |Â
show 1 more comment
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
sed variable-substitution
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 withmake
?
â 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
 |Â
show 1 more comment
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
sed variable-substitution
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
sed variable-substitution
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 withmake
?
â 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
 |Â
show 1 more comment
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 withmake
?
â 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
 |Â
show 1 more comment
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.
add a comment |Â
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.
add a comment |Â
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.
add a comment |Â
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.
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.
answered Sep 26 '17 at 8:05
Kusalananda
106k14209327
106k14209327
add a comment |Â
add a comment |Â
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