Once again I need a hint for awk. My aim is to do two calculations on a specific part of a field.
But for the beginning I'll start with one calculation.
If this regex prints all the lines to stdout
my task is to fetch the maximum and average for that specific part.
My first attempt gives me all the lines for that month, but I need only the result for that month, beside that it prints to stdout a last line with the name of the matched regex.
How to make that calculation for only the range of the regex $3 ~ /^June$/; and print just the result without all the other lines?
Can anybody help? Thanks in advance.
But for the beginning I'll start with one calculation.
If this regex prints all the lines to stdout
Code:
awk '$3 ~ /^June$/' datafile.txt
My first attempt gives me all the lines for that month, but I need only the result for that month, beside that it prints to stdout a last line with the name of the matched regex.
Code:
awk '$3 ~ /^June$/; {if ($2>max) max=$2} END { print max};' datafile.txt
Can anybody help? Thanks in advance.