Re: Case statement

From: Bill Marcum (bmarcum_at_iglou.com.urgent)
Date: 05/31/05


Date: Tue, 31 May 2005 08:25:31 -0400

On Tue, 31 May 2005 12:04:48 +0000 (UTC), William
  <fred@nosmapherethankyou.com> wrote:
> Hi,
>
> I'm a bit stuck with the below case statement, I'm looking at taking input
> from a user using read command, then evaluating this string to see if it is
> either within a certain numeric range i.e. 100-60000. However when I try to
> specify a range it's not working. If I input 100, I get something else
> returned, I'm quite new to shell scripting and I guess I've not written the
> numeric range correctly?
>
The [x-y] type of expression is strictly for matching characters, not
numbers. To match a range like 100-60000 in a case statement, you would
write something like
1[0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-5][0-9][0-9][0-9][0-9]|60000)

It might be simpler to use an if statement instead:
if [ "$VARIABLE" -ge 100 ] && [ "$VARIABLE" -le 60000 ]

-- 
Depend on the rabbit's foot if you will, but remember, it didn't help
the rabbit.
		-- R.E. Shay


Relevant Pages

  • Re: [Info-ingres] Need help Appending an extra footer line after using COPY .. INTO output_file,
    ... command, as that's the only thing after the 'cat' command line. ... David G. Brooks ... (shell scripting, declarations, etc.) ... Have both queries write to seperate files then append them at the OS ...
    (comp.databases.ingres)
  • Re: CM11A lockup
    ... a quick power cycle on the CM11A was always the fix. ... Just checking for a repeated command (stuck ... rogue transmitter was issuing about a command each second, ...
    (comp.home.automation)
  • Re: Why Cant Public Wi-Fi Be Made Secure?
    ... Sometimes, conferences host as to solar landscapes, unless they're ... stuck. ... If you'll command Rifaat's circle with turns, ...
    (sci.crypt)
  • Re: Fedora 8 install gets stuck
    ... There was one time when I tried running the installer and it did not get stuck, but I aborted the installation as anaconda got started to experiment with the kernel command line parameters. ... The same Fedora 8 media installed without any problem on a desktop computer. ...
    (Fedora)
  • Re: Batch script for maintaing remote services
    ... I want to kill this service before sc command go on stopping ... Does the loop breaks when it finds "stopped" status for a particular ... But how will I kill this service if it gets stuck in ... command parameter, makes sure that next service is only ...
    (microsoft.public.windowsxp.general)