This shell script gets me the max and min values, but I would like to get those values and the associated students when there are repeats.
Code:
#!/bin/sh
Notamax=0
Notamin=0
alumneMax=''
alumneMin=''
while IFS=";" read alumne nota
do
(( nota > Notamax )) && Notamax=$nota alumneMax=$alumne
(( nota < Notamin || Notamin == 0)) && Notamin=$nota alumneMin=$alumne
done <notas.txt
echo "Nota maxima $Notamax ** Alumnos con nota maxima: $alumneMax"
echo "Nota minima $Notamin ** Alumnos con nota minima: $alumneMin"
notas.txt
pepe;5
marcos;7
marta;70
luis;70
ana;5
Actual output
Nota maxima 70 ** Alumnos con nota maxima: marta
Nota minima 5 ** Alumnos con nota minima: pepe
Desired output
Max: marta 70, luis 70
Min: pepe 5, ana 5
How could I achieve it?