hi guys im a newbie at scripting and am writhing a basic phone dir script to teach myself scripting now the problem i have is i need to make sure the tel number entered to the script is only 8 digits and the first number is not a zero. to use the script i do this ./dir.sh "name" 12345678 can anyone help me here thanks in advance if you can
n='12345678'; echo ${#n}
n='12345678'; echo ${n%???????}
I think that should help you a bit =)
maybe you want to create a small and simple script like this:
case $1 in
[0-9]*) if [ `echo $1 | wc -c` -ne 9 -o `echo $1 | cut -c1` -eq 0 ]; then
echo no
else
echo yes
fi
;;
*)
echo usage
;;
esac
Thank you cabrao that is the code i need im learning the linux scripting and having so much fun wish i had droped windows and done this a long time ago thanks again cabrao