number of characters in a string

Hi there, I have some user input in a variable called $VAR, and i need to ensure that the string is 5 or less characters .... does anybody know how i can count the characters in the variables ?

any help would be great, cheers

Hi.

$ X=12345
$ echo ${#X}
5

if [ ${#X} -le 5 ]; then
 ....
fi

myx=12345
echo $myx | awk '{print length($1)}'