I need to make ~96 configure files from a template config file which has hundreds of rows that looks like:
Those config files are named in sequence from S01.config, S02.config, ... etc
with different avg_ins values according to a table
Only one row needs to be changed with different values of
avg_ins . What I tried is first use echo to create a tmp file:
then manually change the corresponding
avg_ins values in the
temp.sh file to have the final script like:
Then run the resulted script to have the 96 config files with corresponding avg_ins values.
What is the better way to handle this with awk by read the table.file into array and then substitute the template.config if possible? Thanks a lot!
Code:
template.config:
[LIB]
#average insert size
avg_ins=1000
......
other information omitted
with different avg_ins values according to a table
Code:
table.file:
S01 600
S02 710
S03 520
S04 450
......
Code:
for i in S{01..96}; do echo "sed 's/avg_ins=1000/avg_ins=600/' template.config > ${i}.config"; done > temp.sh
Code:
sed 's/avg_ins=1000/avg_ins=600/' template.config > S01.config
sed 's/avg_ins=1000/avg_ins=710/' template.config > S02.config
sed 's/avg_ins=1000/avg_ins=520/' template.config > S03.config
...
What is the better way to handle this with awk by read the table.file into array and then substitute the template.config if possible? Thanks a lot!