Is there a function to return the length of a string?
The fastest way, not requiring external programs (but usable only with ["BASH"] and KornShell):
${#varname}
or
expr "$varname" : '.*'
(expr prints the number of characters matching the pattern .*, which is the length of the string)
or
expr length "$varname"
(for a BSD/GNU version of expr. Do not use this, because it is not ["POSIX"]).