i have to check if is input number or text, i case that is text then exit script
exaple is hrere, but is not working
check_it()
{
if [ "$1" != +([a-zA-Z]) ]
then
if (( $1 > 0 && $1 < 13 ));
then
echo "input number is ok"
else
echo "number not ok"
exit 1
fi
else
echo "just numbers please"
exit 1
fi
}
case $1 in
0*) echo "sorry, no leading zeroes"
exit 1;;
"") echo "input parameter is required"
exit 1;;
esac
Not sure what you were trying to achieve with both the check_it function and the case statement. You can do it all using a case statement as shown in the following example
#!/usr/bin/bash
shopt -s extglob
INPUT="123456"
case $INPUT in
( +([[:digit:]]) ) echo "INPUT is all numbers" ;;
*) echo "INPUT is not all numbers" ;;
esac