1

The input file looks like.

abc=1.01
abc=0.99
abc=2.1
abc=0.9
abc=2.23e-07
abc=1.22

I would like to print the value of abc is less than 1.0. So that output should look like.

abc=0.99
abc=0.9
abc=2.23e-07

However, when I run the code, the last line is absent. Tried as

awk -F '=' '{if($2<1) print $0}' file

awk --version

GNU Awk 3.1.7
  • 1
    @msp9011 bc an option? – muru Jun 18 at 6:43
  • 2
    @msp9011: I'm missing the point probably, but what's wrong with your attempt. You seem to be getting the output as needed? – Inian Jun 18 at 6:44
  • 2
    I'm confused. Isn't this script doing what you want? 2.23e-07 is less than 2? Also, you can simplify the script to awk -F '=' '$2<1' file. – Sparhawk Jun 18 at 6:44
  • 1
  • 1
    You're not in a locale where , is the decimal separator, are you? Try LC_ALL=C awk -F '=' '$2<1' file – muru Jun 18 at 6:51
0

I think it wll work once you rewrite abc=2.23e-07 to abc=2.23*e-07.

  • 2
    You should probably test it too... – Kusalananda Jun 18 at 8:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.