Artificial intelligent assistant

Compare records value with each others Consider the below file: foo,boo,900 foo,boo,900 foo,boo,850 I need to compare the a field (`$3`) with the next record, if the difference is equal or more than 50, then print the record. i.e from the sample above, `$3` from second record - `$3` from the third record = 50, then the output would be: foo,boo,850

You can try this `awk`


awk -F"," 'NR != 1 { if ((x - $3) >= 50) print $0; } { x = $3 }' file


and this one if you don't want to print row if filed `$1` changed:


awk -F"," 'NR != 1 { if ($1 == fc && (x - $3) >= 50) print $0; } { x = $3; fc = $1; }' file

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 05c7340cfba92793cc975b61844267d5