Number or Character

How to find that a given variable is a number or character?

e.g.

echo "Enter the number"
read var

If "$var" is a number then display "Number has been entered"
else display "Character has been entered".

Thanking you in advance

Anything that the user enters will be one or more characters. If you want to determine if that string of characters represents a number, you need to define things much more. Which of these should be rejected?
0001
1.345
-50
0xFFFF
And the list could go on and on. We also need to know what shell you are using. Because we don't know these things we are likely to give you an answer that doesn't solve your problem. So then we need several posts before we can focus on your problem. Please help us help you by providing more information about your problem.

But I guess that I'll get the ball rolling. I will assume that you are using ksh. And I'll assume that you want integers in base 10:

#! /usr/bin/ksh
echo Enter an integer-- \\c
while read var ; do
       if [[ $var = ?(+|-)+([0-9]) ]] ; then
             echo $var is an integer
       else
             echo $var is not an integer
       fi
       echo Enter an integer -- \\c
done
exit 0

For those using the Bourne shell rather than the Korn shell, you will usually go through expr.

#!/bin/sh

var="$1"
if [ "x$var" = x ]; then
    echo No input
elif [ `expr "$var" : '[0-9][0-9]*$'` -gt 0 -o  `expr "$var" : '[-+][0-9][0-9]*$'` -gt 0 ]; then
    echo $var is an integer
else
    echo $var is not an integer
fi

I believe Perderabo's solution in ksh has the advantage of not calling an external program to do some of the work.

Thank you very much Perderabo and criglerj.

I wanted to check integer (base 10)

In next posts I will try to be more specific