I am trying to sort column 2 considering blocks of 5 rows all time.
E.g.
First block rows 1 to 5 : Sort column 2 in ascending order
Second block rows 6 to 10 : Sort column 2 in descending order
Do this operation in all file
Input file
P 45683.00 39785.00 1 12
P 45685.00 39785.00 1 12
P 45687.00 39785.00 1 12
P 45689.00 39785.00 1 12
P 45691.00 39785.00 1 12
P 45683.00 39795.00 1 12
P 45685.00 39795.00 1 12
P 45687.00 39795.00 1 12
P 45689.00 39795.00 1 12
P 45691.00 39795.00 1 12
P 45683.00 39805.00 1 12
P 45685.00 39805.00 1 12
P 45687.00 39805.00 1 12
P 45689.00 39805.00 1 12
P 45691.00 39805.00 1 12
P 45683.00 39815.00 1 12
P 45685.00 39815.00 1 12
P 45687.00 39815.00 1 12
P 45689.00 39815.00 1 12
P 45691.00 39815.00 1 12
desired output
P 45683.00 39785.00 1 12
P 45685.00 39785.00 1 12
P 45687.00 39785.00 1 12
P 45689.00 39785.00 1 12
P 45691.00 39785.00 1 12
P 45691.00 39795.00 1 12
P 45689.00 39795.00 1 12
P 45687.00 39795.00 1 12
P 45685.00 39795.00 1 12
P 45683.00 39795.00 1 12
P 45683.00 39805.00 1 12
P 45685.00 39805.00 1 12
P 45687.00 39805.00 1 12
P 45689.00 39805.00 1 12
P 45691.00 39805.00 1 12
P 45691.00 39815.00 1 12
P 45689.00 39815.00 1 12
P 45687.00 39815.00 1 12
P 45685.00 39815.00 1 12
P 45683.00 39815.00 1 12
I tried
awk '/45691.00/{"awk \\$0+0==\\$0 "file | getline x}
{print x"~"FNR"~"$0 | "sort -k2,2n "}'
Thanks in advance