I want to find the most positive and negative value for each row and also define its position (based on column #)
So the output would look something like:
Jake 6 4 -2 7
Jerry 7 6 -6 7
Timmy 9 5 -8 4
Where the first column is name, 2nd column is the most positive value, 3rd is its column position, 4th column is the most negative value and 5th column is the column position of the most negative value.
awk '{
max=0;min=0
for(i=2;i<=NF;i++) {
if ( max < $i ) {max=$i;maxpos=i-1}
if ( min > $i ) {min=$i;minpos=i-1}
if (i == NF) { print $1,max,maxpos,min,minpos}
}
}
' filename