DomainsFeatured DomainsFeatured - 1 month ago 6
Linux Question

Remove Lines With Number Less Than X In Nth Field

I have a file consisting of lines like this:

ExampleText | En | 1.0
ExampledText | Es | 0.9
ExamplesText | En | 0.9994
ExampleTexts | Br | 0.991
ExampledText | Es | 0.83324
ExamplerText | En | 0.4494


Using
grep .*| En
, I can get all the lines containing
En
. However, how can I also remove all values that contain less than 0.5 in the last column?

Thus, the output is:

ExampleText | En | 1.0
ExamplesText | En | 0.9994


Your positive input is highly appreciated.

Answer
awk '$2 == "En" && $3 >= .5' FS=' \\| '
  1. Set field separator to |

  2. Match if field 2 equals En and field 3 is greater or equal to .5