0

Im trying to get the internet speed and compare it to various values and print if its good or not. All this is done in my macOS zsh terminal.

Var2=$(ping -c 4 www.google.com | tail -1| awk '{print $4}' | cut -d '/' -f 2)
  echo "Average ping time to google.com is $Var2"
  if (( $Var2 < 7 ))
  then
      echo Excellent Connection
  elif (( $Var2 < 7.5 ))
  then
      echo Good Connection
  elif (( $Var2 < 8 ))
  then
      echo Slow Connection
  elif (( $Var2 < 8.1 ))
  then
      echo Bad Connection
  fi

This causes a syntax error: invalid arithmetic operator (error token is ".609 < 7 ") four times.

Boros
  • 23
  • 1
  • 7

0 Answers0