Gents,
Please i need your help.
Using the file2.txt i will like to replace values in file3.txt.
Example in file 2 column 1 is the value to find in file3.txt and replace with value in colunm2 (file2.txt).
Example
file2.txt
21 1209
22 1210
file3.txt
SCI TB Timestamp Local : 8/30/17 7:52:52.980 AM
File # : 21
Is Raw : false
Shot # : 1752
Swath Name : 2567
Tape # : 3189
Tape Label : C4
________________________________________________________________________
SCI TB Timestamp Local : 8/30/17 7:51:52.980 AM
File # : 21
Is Raw : false
Shot # : 1752
Swath Name : 2568
Tape # : 3188
Tape Label : C4
The desired output should be (file4.txt)
SCI TB Timestamp Local : 8/30/17 7:52:52.980 AM
File # : 21
Is Raw : false
Shot # : 1752
Swath Name : 2567
Tape # : 3189
Tape Label : C4
________________________________________________________________________
SCI TB Timestamp Local : 8/30/17 7:51:52.980 AM
File # : 1209
Is Raw : false
Shot # : 1752
Swath Name : 2568
Tape # : 3188
Tape Label : C4
I use this code to fix this
awk 'NR==FNR{a[$1]=$2; next} /File # :/{gsub(/ /,"",$NF); $NF=" "a[$NF]}1' file2.txt FS=":" OFS=":" file3.txt > file4.txt
The problem I have is.. In file3.txt i have many File # : 21
which correspond to different record information.. Then what I like is to do the replacement ONLY where it is Tape # : 3188..
SCI TB Timestamp Local : 8/30/17 7:51:52.980 AM
File # : 1209
Is Raw : false
Shot # : 1752
Swath Name : 2568
Tape # : 3188
Tape Label : C4
Attached examples with more information and desired output file...
the original file is hug and contends a lot of data to replace, then i add small files with examples..
Appreciate your help