Bash check a variable is a number or text

#!/bin/bash

var=a

if [ "$var" -eq "$var" ] 2>/dev/null
then
  echo number
else
  echo not a number
fi

Redirection of standard error is there to hide the “integer expression expected” message that bash prints out in case we do not have a number.