I have a small bash program, that allows me to compare tables (having similar naming style) and that copies to another directory the file having the highest value at the first row of the fourth column (with space separator) (the values of the fourth column are decimal numbers e.g. 1111.22).#! /bin/bashriver=lobith_rhinehighest=1for model in H08do  for gcm in IPSL-CM5A-LR  do    for scenario in hist rcp8p5    do      for x in ${model}_${gcm}_${scenario}_${river}[1-9]/${model}_${gcm}_${scenario}_${river}[1-9].txt      do        fourth=$(awk 'NR==1{print $4}' $x)        if [ $highest -lt $fourth ];then            highest=$fourth            hifile=$x        fi      done      echo highest was $highest in $hifile      cp $hifile /home/steve/high_test/${model}_${gcm}_${scenario}_${river}.txt    done  donedoneUnfortunately, the line 13 if [ $highest -lt $fourth ];then produces the following error message:integer expression expectedSo, I read some documentation about comparisons operators, and found that I can replace the problematic line by if [ $highest \< $fourth ];thenBut this is not working properly since it just compares the ascii alphabetic order values rather than the entire value.Does anyone has an idea about how to handle those issues?
ERROR: integer expression expected - comparing tables
bash;ascii
Ok that is a workaround that should work#! /bin/bashriver=lobith_rhinehighest=1for model in H08do  for gcm in IPSL-CM5A-LR  do    for scenario in hist rcp8p5    do      RESULT=$(awk 'FNR==1 {print $4, FILENAME}' ${model}_${gcm}_${scenario}_${river}[1-9]/${model}_${gcm}_${scenario}_${river}[1-9].txt | sort -n -r| head -1)       highest=$(echo $RESULT | cut -d ' ' -f1 )      hifile=$(echo $RESULT | cut -d ' ' -f2 )      echo highest was $highest in $hifile      cp $hifile /home/steve/high_test/${model}_${gcm}_${scenario}_${river}.txt    done  donedoneThe idea is inside the awk command over a bunch of files,  awk 'FNR==1 {print $4, FILENAME}' *txt | sort -n -r| head -1 | cut -d ' ' -f2where:FNR is the current file record number and FILENAME is the current file namesort is the sort commandcut is the cut commandPs> it's possible to think a solution without sort and head but only with awk. awk 'FNR==1 {i++; A[i]=$4; B[i]=FILENAME}      END{ c=A[1];d=B[1];            for (j=2;j<i;j++){            if (A[j]>c){c=A[j];d=B[j];}            }           print c,d ;        }' *txt