Re: Case statement
From: William (fred_at_nosmapherethankyou.com)
Date: 05/31/05
- Next message: William: "Re: Case statement"
- Previous message: Sun Xun: "Re: How to read text from a file in shell scripting"
- In reply to: joe_at_invalid.address: "Re: Case statement"
- Next in thread: William: "Re: Case statement"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 31 May 2005 14:59:58 +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
Thanks Joe!
I'll get the hang of this scripting lark yet :-)
-- Regards William
- Next message: William: "Re: Case statement"
- Previous message: Sun Xun: "Re: How to read text from a file in shell scripting"
- In reply to: joe_at_invalid.address: "Re: Case statement"
- Next in thread: William: "Re: Case statement"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|