I have 2 files like these:
file1
1 2 3 . . .
1 -2 4 . . .
1 2 5 . . .
. . . . . .
. . . . .
file 2
1 0.33 3 . . .
2 0.14 4 . . .
3 2.155 5 . . .
. . . . . .
. . . . . .
I need to check line by line the condition ($1==1 && $2==-2) in file1 and modify the corresponding line in file2, with $3=-2
I am trying with:
awk -F '\t' '{ BEGIN { FS=OFS="\t" } if ($1==1 && ($2==-2) {getline < "file2" ; $3=8; print $0} else {getline < "file2" ; print $0} }' file1
So that the output file should be:
1 0.33 3 . . .
2 0.14 8 . . .
3 2.155 5 . . .
. . . . . .
. . . . . .
but it seems like some character or space is modified.
Maybe with Python it is simpler to tackle this problem?
Any suggestion?
Since you asked about python