I have a criteria like bloew.
user entered the uid like <START_UID>-<END_UID>
it menas if he enter 00001-12345
START_UID=00001 and END_UID=12345
both are separated by `-`.
I need to validate whether user entered uids like above, he should have to enter '-', otherwise error msg has to print. And need to validate whether both uids are numeric only. If he enter 00001-1234( error msg has to print. And it should accepts only one occurance of '-' symbol.
can any one give the solution.I am trying with this sol
OPTARG=$1
cnt=1;
while [ $cnt -le $length ]
do
c=$(echo "$OPTARG"|cut -c$cnt-$cnt)
if [[ $c = "-" ]]
then
FIRST_FIELD=${OPTARG%%-}
SECOND_FIELD=${OPTARG##-}
fi
((cnt+=1))
done
But when i enter 3663-929(
-bash: syntax error near unexpected token `('
This error am getting .