Skip to content
Advertisement

How do I find the number of elements in a column greater than a given number in Linux?

I have a text file of list of students with Marks and I want to find how many of them secured more than 80 in Maths, Physics and then Maths and Physics combined. What should be the Linux command to do this?

The text file is here:

JavaScript

Advertisement

Answer

This can be achieved using awk (don’t use grep because this is not fit for number arithmetic). An example:

JavaScript

This needs to be improved: how to remove the cat command, how to check the sum of both columns, why is the title present, …? But at least you have something to start.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement