Hey There,
In bash (and similar shells) you can use read with the -n flag, like:
read -n4
if you want to limit the variable input to 4 characters.
If you want to just trim your variables, you can check the length of a variable by gettings the length value and running a simple if compare. so, if:
var=12345
echo $var = 12345
echo ${#var} = 5
if [ ${#var} -gt 4 ]
then
bail
fi
Hope that helps
, Mike