function num_check() { read -p "$1" as until expr $as - 1 >>/dev/null 2>/dev/null do read -p "$2 should be numeric please enter again" as done echo $as } function char_check() { read -p "$1" as while expr $as - 1 >>/dev/null 2>/dev/null do read -p "$2 should not be numeric please enter again" as done echo $as } function null_check() { read -p "$1" as while [ -z $as ] do read -p "$2 should not be null " as done echo $as } function alphacheck() { read -p "$1" as while echo $as | grep [0-9\!\@\#$\%\^\&\*\(\)\-\_\|] 2>>/dev/null >>/dev/null do read -p "$2 should be alphabet only" as done echo $as } # # sample calling for the script # # #z=`num_check "Please enter the no" "Customer no" ` #echo $z #echo `expr $z + 1` #y=`char_check "Please enter the name" "Customer name"` #echo $y #echo $y | wc -c #x=`null_check "Please enter enrollment no" "enrollment no"` #q=`alphacheck "Please enter the name" "Customer name"` #echo $q