Searching max

A direct translation of

awk -F. '{n=256*$3+$4} n>m{m=n; ip=$0} END{print ip}' file*

into shell script:

n=0 m=0
cat file* |
{ 
  while IFS=. read a b c d
  do
    n=$(( 256 * c + d )) 
    if [ $n -gt $m ]; then
      m=$n ip=$a.$b.$c.$d
    fi
  done
  echo "$ip"
}

For shell script I would prefer RudiC's sort approach...

Having 4 active threads about extremely similar topics probably doesn't help...

1 Like

I was about to comment similarly.