Replace whole lines in the file from different files
Hi all,
I have two parameter blocks in a configuration file, file1.conf.
First parameter block starts with PWAT-PARM1 and
ends with END PWAT-PARM1.
Second parameter block starts with PWAT-PARM2 and
ends with END PWAT-PARM2 (please see below in file1.conf).
file1.conf is fixed width columns and numeric values are written in fortran format.
I don't know how to update numeric values in file1.conf from two different files, file2.txt and file3.txt for each iteration.
Thus, numeric values in the first parameter block (PWAT-PARM1) should be updated from file2.txt
and, numeric values in the second parameter block (PWAT-PARM2) should be updated from file3.txt
<file1.conf>
<file2.txt>
<file3.txt>
After first iteration, for example, file1.conf should look like this.
Seems to me, sed or awk would be a solution, but I don't know how to solve it.
I searched this forum using key word "replace lines" and "replace pattern match", but no luck.
Any help would be greatly appreciated.
Thanks to you, I am almost got the solution, but I don't know how to loop in getline from two files. Only first line from file2.txt and file3.txt is updated in file.conf. For next iteration, file.conf should be updated with second line from these two files.
anyways... the problem is 2-fold. I think what you want is a bunch of
different configuration files in order to do some serious testing.
I don't believe you even need an original configuration file.
So, if I'm understanding you correctly:
You have a list of 2 different sets of data that are required for a single configuration.
Each configuration should contain one line from each set of data.
So in the end, you should have as many configuration files as you have lines of data.
To that end, here's the solution:
This script can be easily modified for any type of configuration file,
and any number of parameters.
Your code is also attractive and looks fine. But, I don't know why I got error message at the end of file.
"./file.sh: line 35: syntax error: unexpected end of file"
Hi
this is my SQL script
$ wc -l insert_into_customers.sql
85601 insert_into_customers.sqlI wish to cut this file into 9 files each 10000 lines (the last one less)
$ wc -l insert_into_customers_00*.sql
10000 insert_into_customers_001.sql
10000 insert_into_customers_002.sql
... (1 Reply)
Hi everyone,
I have two files (A and B) and want to combine them to one by always taking 10 rows from file A and subsequently 6 lines from file B. This process shall be repeated 40 times (file A = 400 lines; file B = 240 lines).
Does anybody have an idea how to do that using perl, awk or sed?... (6 Replies)
Hi everybody,
I am a newbie in shell scripting and I'm trying to write a script which reads lines from a file, searching some of this lines to change a specified number. I want to replace the line for another in the file.
I have to replace multiples lines, so I have a for. Now I am trying with... (1 Reply)
Hello,
I have 8 lines containing these unique words in both files
645147468537
673962863160
673962864957
691717701950
707917019907
790085591726
792975507744
852174812753
file.dat.orig (has 1000 lines) and file.dat(has only 8 lines)
I want to replace those lines in file.dat.orig by... (1 Reply)
Hello,
i usually use this for one tag or line:
find . -type f -exec replace "whatever goes here" "" -- {} \;
but i want to replace three lines in a file for example this:
<script language=javascript>< ... (1 Reply)
I've got a file full of numbers, example:
cat test.file
60835287
0
51758036
40242437
0
32737144
0
24179513
0
4131489957
I want to replace those numbers (4 Replies)
Hello
I am a beginner in shell script.
I was trying to find a way to replace multiple lines of a file with different set of multiple line.
sed -n '/begin/,/end/p' < sample1.txt >test.txt
UNEDITED=`cat test.txt`
vi test.txt
EDITED=`cat test.txt`... (2 Replies)
Suppose i have two files
file1.txt
Name : Raju
Address:rt8pouououoiu
City:tyretyeuetu
file2.txt
Address :28a
The line "address:28a" in file2 has to get replaced in the address line of file1 ..
The output should be
Name :Raju
Address:28a
city :tyretyeuetu
Please help me... (2 Replies)