#!/bin/bash var=a if [ -n "$var" ] && [ "$var" -eq "$var" ] 2>/dev/null; then echo number else echo not a number fi