Help with if loop (string comparison)

Hi

Can someone please tell me what is wrong with this (ksh)..

	if [[ ${COMP_TEMP} = [0-9]+ ]] then
		echo ${COMP_TEMP}
	fi

What i need here is, say if the variable is a 1 or 2 digit number, then execute the if loop. Basically the variable can either be 1-30 or some other character sequence say '?', '&&' etc

Thanks.

try this

x=`echo $COMP_TEMP | wc -c `
if [ $x -lt 4 ] then
echo $COMP_TEMP
fi

Thanks, but that ain't going to work cause both 1 and ? are two bytes each.

The variable can either be a number from 1-30 or it can be some other character. I want the if loop to be a success only if the variable is a number from 1-30.

Tried the below and it seems to work. Any idea why '+' doesn't work as intended? (1 or more)

if [[ ${COMP_TEMP} = [0-9]* ]] then

Thanks

What ksh version are you using? The following works on ksh93 and recent versions of pdksh:

COMP_TEMP=12
[[ $COMP_TEMP == +([0-9]) ]] && print Match

[0-9] is the range, and ksh regex says "match one or more" with +(list)