Re: Case statement
From: William (fred_at_nosmapherethankyou.com)
Date: 05/31/05
- Next message: balgach_at_gmail.com: "using grep to find IP address..."
- Previous message: William: "Re: Case statement"
- In reply to: joe_at_invalid.address: "Re: Case statement"
- Next in thread: Ed Morton: "Re: Case statement"
- Reply: Ed Morton: "Re: Case statement"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 31 May 2005 15:10:56 +0000 (UTC)
<joe@invalid.address> wrote:
> case blocks don't work like that. The cases match string patterns, but
> don't interpret them. You want to first ensure that the input is
> numeric, and then test for the range. for example
>
> case $1 in
> *[!0-9]*) echo Error, input is not numeric
> ;;
> *) if [ "$1" -ge 100 -a "$1" -le 6000 ];then
> echo input is between 100 and 6000
> else
> echo input is not between 100 and 6000
> fi
> ;;
> esac
>
> Joe
Apologies for asking another daft question :-(
If a user were to input say.
Enter a value: 1 2 3 4
Is there any way of catching that to produce an error? with the above being
considered.
-- Regards William
- Next message: balgach_at_gmail.com: "using grep to find IP address..."
- Previous message: William: "Re: Case statement"
- In reply to: joe_at_invalid.address: "Re: Case statement"
- Next in thread: Ed Morton: "Re: Case statement"
- Reply: Ed Morton: "Re: Case statement"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|