Comparing string and integer in IF

hi,
I need to create an IF condition. I read a line from a file and get the 5 word using space as a delimited. This word can have only two values either '*' or '1-5'

I need to write an IF condition for two cases. I can either compare it to * or 1-5(or even 1 by cutting and getting only the first character).
But when I write it

eg, if [$var -eq '*' ]

If the value is 1-5 it says integer argument expected. If I write

if [ $var == 1 ]

In this case when the value is '' it says string expected. How can I resolve this. Cannt I declare that the $var is always goiing to be a char. So I can use -eq '' and -eq '1-5'.

The -eq operator is for numeric test.
For a string test, you must use the = operator.

if [ "$var" = '*' ]
if [ "$var" = '1-5' ]

Jean-Pierre.

> var1="*"
> if [ "$var1" = "*" ] ; then echo "match"; fi
match
> if [ "$var1" = "1" ] ; then echo "match"; fi
> 

> var1="1"
> if [ "$var1" = "*" ] ; then echo "match"; fi
> if [ "$var1" = "1" ] ; then echo "match"; fi
match

> var1=1
> if [ "$var1" = "1" ] ; then echo "match"; fi
match

Or you could simply use case instead.

case $var in '*') echo "It's full of stars";; 1-5) echo "Working one to five";; esac