Domanda

I have a (maybe) silly question.

My data: File 1

1234.34  a 1235.34 d
3456.23  b 3457.23 e
2325.89  c 2327.89 f 

I want something like

awk '{if($1==$3) print $4}'

But of course if I do this, it will print nothing. So I want to modify the "precision" of $3 (in this case)

in the sense that when awk read $3 it finds this:

124
345
232

then it must be a way to do this, but I don't know it.

awk '{if($1==(three digits precision $3)) print $4}'

Help?

È stato utile?

Soluzione

You could calculate the difference of the two values:

awk '$1 - $3 < 0.01 || $3 - $1 < 0.01 {print $4}' file
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top