Hello Everyone,
I have two files, similar to the following:
File 1:
8010 ITEM01 CODE1 FLAG1
filler
filler
7020 OBJECT CODE2 FLAG2
filler
6010 THING1 CODE4 FLAG4
6011 ITEM20 CODE7 FLAG7
File 2 contains:
6020 ITEM01 CODEA FLAGA
filler
filler
filler
7000 OBJECT CODEB FLAGB
filler
filler
4020 THING1 CODEC FLAGC
2211 ITEM20 CODED FLAGD
I want to compare file 1 and two by the keyword in column two (in this example, the items in column two are ITEM01, OBJECT, THING1, and ITEM20). If the keyword if found in both files, then the CODE/FLAG from file2 will overwrite the code/flag found in file1 like so:
8010 ITEM01 CODEA FLAGA
filler
filler
7020 OBJECT CODEB FLAGB
filler
6010 THING1 CODEC FLAGC
6011 ITEM20 CODED FLAGD
I tried using the "cut -b 7-12" command, since I know that the keyword is found in byte positions 7-12 and tried comparing what i extracted between both files, but that doesn't seem to work. I've also tried cutting the files so that in one file, I have the keywords and the other file, I have the code/flag. I then tried joining the files. This didn't work since i have filler text in between the lines of the keywords. Any suggestions?