5500 57005600 58005700 58005600 59005900 61005900 61005900 61005800 60005800 61005900 61005800 62005700 5800I have a file with two columns as above. I need to find out min of every two rows in the first column and max of every two rows in the second column.How can it be achieved using awk?Desired output would beMin      Max5500     58005600     59005900     61005800     61005800     61005700     6200  
Max of 2nd column and Min of 1st column, comparing two rows at a time
text processing;awk;numeric data
$ awk 'BEGIN { print Min, Max } {a=$1; b=$2; getline; print ($1<a?$1:a), ($2>b?$2:b)}' data.inMin Max5500 58005600 59005900 61005800 61005800 61005700 6200The awk code saves the current values in column one and two into the variables a and b respectively.  It then reads the next line explicitly and prints the minimum of a and the new value in column one together with the maximum of b and the new value of column two.($1 < a ? $1 : a) is using the ternary operator ?: to make a comparison and choose a value depending on the outcome of that comparison.If you want tab-delimited output:$ awk 'BEGIN {OFS=\t; print Min, Max} {a=$1; b=$2; getline; print ($1<a?$1:a), ($2>b?$2:b)}' data.inMin     Max5500    58005600    59005900    61005800    61005800    61005700    6200