Gents,
Kindly can you help me to update a file extracting the data from other file.
I have:
file1
The key in this file is substr($0,4,21), and I need to update the columns 6 and 7 using the information for file2.
S 21133.00 21535.00 1 0 919088.8 1843754.5 58.9229000049
S 21135.00 21535.00 1 0 919017.0 1843719.4 58.0229000232
S 21137.00 21535.00 1 0 919013.1 1843812.0 57.5229000414
S 21139.00 21535.00 1 0 919001.4 1843843.9 57.3229000554
S 21139.00 21537.00 1 0 919041.1 1843872.8 56.5229000736
S 21137.00 21537.00 1 0 919062.5 1843831.5 57.5229000918
file2
in this file the key is substr($0,1,21). Here I have the correct values that need to be updated in file1 Columns 5 and 5
21133.00 21535.00 1 919070.8 1843749.0
21387.00 21593.00 1 917152.3 1849943.2
21135.00 21535.00 1 919047.0 1843759.4
21385.00 21593.00 1 917178.4 1849896.6
21139.00 21537.00 1 917132.2 1850278.1
21137.00 21535.00 1 919023.1 1843802.0
21383.00 21593.00 1 917196.2 1849861.6
21183.00 21561.00 1 919011.1 1845127.6
21139.00 21535.00 1 917198.1 1850262.6
output
Mi output should be like this
S 21137.00 21535.00 1 0 919070.8 1843749.0 57.5229000414
S 21139.00 21535.00 1 0 917198.1 1850262.6 57.3229000554
S 21139.00 21537.00 1 0 917132.2 1850278.1 56.5229000736
S 21137.00 21535.00 1 0 919023.1 1843802.0 57.5229000918
I have try using
ask 'FNR==NR{a[NR]=$6;next}{$4=a[FNR]}1' file1 file2
but it is to replace one column,, the problem I have is that I need to find the key and replace the values , like I use idex and match in excel formulas.
Thanks for your support