Skip to main content
Based on Ed's tip, made question clearer.
Source Link

I have the following awk script:

{ if ($1 > 1000) { print $0 } } 

It should print all the lines where the value of the first and only column is is above 1000.

Here is the test data:

1,151 1001,055 756,75788 

Using awk -f my_script.awk my_data, I have the following output:

1001,055 756,75788 

Where I am expecting:

1001,055 

Awk version is:

GNU Awk 5.0.0, API: 2.0 (GNU MPFR 4.0.2, GNU MP 6.1.2) 

What I am doing wrong ?

Edit:

as said in the comments:

Coma is not a separator here, it is the decimal separator, used in french and according to wikipedia, in all notation systems except the english one.

Edit 2: There is only one column in the example data. In the real data, field separator is ";".

I have the following awk script:

{ if ($1 > 1000) { print $0 } } 

It should print all the lines where the value of the first column is above 1000.

Here is the test data:

1,151 1001,055 756,75788 

Using awk -f my_script.awk my_data, I have the following output:

1001,055 756,75788 

Where I am expecting:

1001,055 

Awk version is:

GNU Awk 5.0.0, API: 2.0 (GNU MPFR 4.0.2, GNU MP 6.1.2) 

What I am doing wrong ?

Edit:

as said in the comments:

Coma is not a separator here, it is the decimal separator, used in french and according to wikipedia, in all notation systems except the english one.

I have the following awk script:

{ if ($1 > 1000) { print $0 } } 

It should print all the lines where the value of the first and only column is above 1000.

Here is the test data:

1,151 1001,055 756,75788 

Using awk -f my_script.awk my_data, I have the following output:

1001,055 756,75788 

Where I am expecting:

1001,055 

Awk version is:

GNU Awk 5.0.0, API: 2.0 (GNU MPFR 4.0.2, GNU MP 6.1.2) 

What I am doing wrong ?

Edit:

as said in the comments:

Coma is not a separator here, it is the decimal separator, used in french and according to wikipedia, in all notation systems except the english one.

Edit 2: There is only one column in the example data. In the real data, field separator is ";".

added 196 characters in body
Source Link

I have the following awk script:

{ if ($1 > 1000) { print $0 } } 

It should print all the lines where the value of the first column is above 1000.

Here is the test data:

1,151 1001,055 756,75788 

Using awk -f my_script.awk my_data, I have the following output:

1001,055 756,75788 

Where I am expecting:

1001,055 

Awk version is:

GNU Awk 5.0.0, API: 2.0 (GNU MPFR 4.0.2, GNU MP 6.1.2) 

What I am doing wrong ?

Edit:

as said in the comments:

Coma is not a separator here, it is the decimal separator, used in french and according to wikipedia, in all notation systems except the english one.

I have the following awk script:

{ if ($1 > 1000) { print $0 } } 

It should print all the lines where the value of the first column is above 1000.

Here is the test data:

1,151 1001,055 756,75788 

Using awk -f my_script.awk my_data, I have the following output:

1001,055 756,75788 

Where I am expecting:

1001,055 

Awk version is:

GNU Awk 5.0.0, API: 2.0 (GNU MPFR 4.0.2, GNU MP 6.1.2) 

What I am doing wrong ?

I have the following awk script:

{ if ($1 > 1000) { print $0 } } 

It should print all the lines where the value of the first column is above 1000.

Here is the test data:

1,151 1001,055 756,75788 

Using awk -f my_script.awk my_data, I have the following output:

1001,055 756,75788 

Where I am expecting:

1001,055 

Awk version is:

GNU Awk 5.0.0, API: 2.0 (GNU MPFR 4.0.2, GNU MP 6.1.2) 

What I am doing wrong ?

Edit:

as said in the comments:

Coma is not a separator here, it is the decimal separator, used in french and according to wikipedia, in all notation systems except the english one.

Source Link

Why is my float comparison in awk not going the expected result?

I have the following awk script:

{ if ($1 > 1000) { print $0 } } 

It should print all the lines where the value of the first column is above 1000.

Here is the test data:

1,151 1001,055 756,75788 

Using awk -f my_script.awk my_data, I have the following output:

1001,055 756,75788 

Where I am expecting:

1001,055 

Awk version is:

GNU Awk 5.0.0, API: 2.0 (GNU MPFR 4.0.2, GNU MP 6.1.2) 

What I am doing wrong ?