Hi ,
I have writen a scipt and passing one Parameter.
In the scipt i want verify the parameter patteren using Case statement.
exp:
sh script.sh 1213
Code:
i want verify the paramater values as only number not charater.
can you please advise.
Hi ,
I have writen a scipt and passing one Parameter.
In the scipt i want verify the parameter patteren using Case statement.
exp:
sh script.sh 1213
Code:
i want verify the paramater values as only number not charater.
can you please advise.
The Case statement will already verify if the parameter is valid or not - whether the parameter is int or char. If the parameter is composed of characters, then the Case statement will select the (*) in its options.
case
1)
2)
*)
esac
If you really want to check the parameter if it's composed of numbers or characters, then use a regular expression.
PARAM=$1
echo ${PARAM} | sed '/[a-z]/!d'
In ksh
[[ $1 == +([0-9]) ]] && echo "is a number" || echo "is NOT a number"
also refer to this thread