Try something like:
$ awk '
BEGIN{print "period", "min", "max"}
!f{min=$2; max=$2; ++f; next}
{max = ($2>max)?$2:max; min = ($2<min)?$2:min; f++}
f==9{print ++a, min, max; f=0}' file
period min max
1 1 5
2 0 6
- When the flag
f
is not set, you assign the second column to max and min variables and start incrementing your flag. - For each line, check the second column. If it is bigger than our max variable assign that column to max. Like wise, if it is smaller than our min variable, assign it to our min variable. Keep incrementing the flag.
- Once the flag reaches 9, print the period number, min and max variables. Reset the flag to 0 and start again afresh from next line.