Reputation: 724
Check values in column 2, if the values are not increment of 50 then print row
Input file
1000 2450 1
1000 2500 1
1000 2501 1
1000 2550 1
1000 2601 1
1000 2650 1
output desired
error 1000 2501 1
error 1000 2601 1
Using answer of Karakfa I tried
awk '{$2%50
{ err = FNR; exit }
END { print "Invalid file on line", err; exit 1}
print "Wrong File :", FILENAME }' file
thanks in advance
Upvotes: 0
Views: 49
Reputation: 67507
$ awk '$2%50{print "error",$0}' file
error 1000 2501 1
error 1000 2601 1
if the value is not multiple of 50, the remainder mod 50 will be nonzero.
I guess this is what you're trying?
$ awk '$2%50 {err=FNR; exit}
END {if(err)
{print "Invalid file on line:", err;
print "Wrong File :", FILENAME;
exit 1}}' file
note END
cannot be in any statement, can appear only as a "condition", similar to BEGIN
.
Upvotes: 3