Hi all,
i need help to replace certain values in a file. I need the script to check and match the ID and exNum1. if match, values in $3 (file2.txt) need to replace the value for 'START' (file1.txt) for each match.
The sample structure is like this:-
File1.txt
ID P_6
START 235411
END 18763
//
ID P_10
START 631012
END 32814
//
ID P_133
START 389417
END 314124
//
File2.txt
ex 21204 22151 P_6
S 21204 22151 P_6 exNum 2
ex 22217 22765 P_6
S 22217 22765 P_6 exNum 1
ex 37193 37735 P_10
S 37193 37735 P_10 exNum 5
ex 37862 38019 P_10
S 37862 38019 P_10 exNum 4
ex 38076 38835 P_10
S 38076 38835 P_10 exNum 3
ex 38880 39050 P_10
S 38880 39050 P_10 exNum 2
ex 39093 39644 P_10
S 39093 39644 P_10 exNum 1
ex 42305 42440 P_133
S 42305 42440 P_133 exNum 3
ex 42496 42656 P_133
S 42496 42656 P_133 exNum 2
ex 42657 42674 P_133
S 42657 42674 P_133 exNum 1
Output (file1.txt) should be updated like this:
ID P_6
START 22765
END 18763
//
ID P_10
START 39644
END 32814
//
ID P_133
START 42674
END 314124
//
I parsed structure of file1.txt using PERL before but i don't know how to change the certain value for a field in it. Any help would be appreciated. Thanks