AWK doesn't filter number 100 in decimal form (100.000) in output locale

Viewed 71

First of all, thank you everyone for your help. I have a problem filtering with AWK with the value 100.000 which is the same same as 100, but is with decimals. I have this file:

1   100
2   100.000
3   99.874
4   67.321

This is my code:

cat example.txt | awk '$2 >= 70 {print $2}'

The output generated is the following

100
99.874

As you can see the value 100.000 will also have to appear. My awk version is mawk 1.3.4 20200120

1 Answers

The behavior depends on your locale settings.

I suggest:

LC_NUMERIC=C mawk '$2 >= 70 {print $2}' example.txt
Related