Grep out rows where the value is greater than 50 in a specific column

I am a beginner and am learning about grep, so here is my question. Using Linux, I want the lines from the file to only show what I have specified. For example, some column shows the length of time in seconds and I want to show only those rows where the seconds are more than 50 seconds. I can tell how many lines cut / sort / uniq / sort is using, but that's not nearly as useful as having the entire line of information at once. Here's just an example. I want to grab lines with times longer than 13.9 sec.

64 bytes from hugs05s22-in-f8.1e100.net (100.100.239.204): icmp_seq=1 ttl=55 time=13.9 ms 
64 bytes from hugs05s22-in-f8.1e100.net (100.100.239.204): icmp_seq=2 ttl=55 time=13.2 ms
64 bytes from hugs05s22-in-f8.1e100.net (100.100.239.204): icmp_seq=3 ttl=55 time=13.9 ms
64 bytes from hugs05s22-in-f8.1e100.net (100.100.239.204): icmp_seq=4 ttl=55 time=18.3 ms
64 bytes from hugs05s22-in-f8.1e100.net (100.100.239.204): icmp_seq=5 ttl=55 time=14.3 ms
64 bytes from hugs05s22-in-f8.1e100.net (100.100.239.204): icmp_seq=6 ttl=55 time=17.7 ms
64 bytes from hugs05s22-in-f8.1e100.net (100.100.239.204): icmp_seq=7 ttl=55 time=13.4 ms

      

I could pull out the entire row with 18.3 / 14.3 / 17.7 (say time = was not part of the column (or heck it was)). Any help in awk, sed or just grep would be appreciated.

+3


source to share


1 answer


Regular expressions are not good for numeric comparisons (you could do that, but it would be cumbersome). Use awk

it has arithmetic operators.



awk -F'[ =]' '$11 > 50'

      

+5


source







All Articles