fork download
  1. #!/bin/bash
  2.  
  3. TEXT='apple V$NFY_Q6_rc V=0.741
  4. apple V$HOXA7_01_rc V=0.454
  5. apple V$ALPHACP1_01_rc V=0.695
  6. orange V$SP4_Q5 V=0.747
  7. grapes V$SP1_Q2_01 V=0.677
  8. grapes V$SP1_Q6_01_rc V=0.685
  9. grapes V$SP1_Q6_rc V=0.884'
  10.  
  11.  
  12. echo "Unsorted:"
  13. awk -F'[ =]' '$NF>a[$1]{a[$1]=$NF;b[$1]=$0}END{for (i in b) print b[i]}' <<< "$TEXT"
  14. echo "========
  15. Sorted:"
  16. awk -F'[ =]' '$NF>a[$1]{a[$1]=$NF;b[$1]=$0}END{for (i in b) print b[i]}' <<< "$TEXT" | sort -t= -nk2
Success #stdin #stdout 0.02s 5312KB
stdin
Standard input is empty
stdout
Unsorted:
orange  V$SP4_Q5    V=0.747
apple   V$NFY_Q6_rc V=0.741
grapes  V$SP1_Q6_rc V=0.884
========
Sorted:
apple   V$NFY_Q6_rc V=0.741
orange  V$SP4_Q5    V=0.747
grapes  V$SP1_Q6_rc V=0.884