Re: .sh check for numeric content

2010-06-27 Thread Anonymous
Giorgos Keramidas keram...@ceid.upatras.gr writes: On Thu, 24 Jun 2010 05:19:53 +0200, Thomas Keusch f...@bsd-solutions-duesseldorf.de wrote: t...@eternity:~$ b=5 t...@eternity:~$ case $b in [0-9] ) echo numeric ;; * ) echo alpha ;; esac numeric

Re: .sh check for numeric content

2010-06-24 Thread Jerry
On Wed, 23 Jun 2010 23:32:57 -0400 (EDT) Karl Vogel vogelke+u...@pobox.com articulated: On Thu, 24 Jun 2010 09:24:39 +0800, Aiza aiz...@comclark.com said: A Receiving a variable from the command line that is suppose to A contain numeric values. How do I code a test to verify the A

Re: .sh check for numeric content

2010-06-24 Thread Thomas
On Thu, Jun 24, 2010 at 12:52:48PM +0800, Aiza wrote: Hello, But when I tried this format [ expr ${dup_times} : [0-9]*$ ] || echo value is not numeric I get the error message no mater what the value is. What am I doing wrong? Even if [ at first glance seems like a special syntax of the

Re: .sh check for numeric content

2010-06-24 Thread RW
On Thu, 24 Jun 2010 05:19:53 +0200 Thomas Keusch f...@bsd-solutions-duesseldorf.de wrote: t...@eternity:~$ b=5 t...@eternity:~$ case $b in [0-9] ) echo numeric ;; * ) echo alpha ;; esac numeric t...@eternity:~$ Works for me. Now try it

Re: .sh check for numeric content

2010-06-24 Thread Thomas
On Thu, Jun 24, 2010 at 12:31:13PM +0200, Thomas wrote: Hello, Even if [ at first glance seems like a special syntax of the shell, it really is just an alternative name or way of calling test(1): $ ls -l $(which test [) -rwxr-xr-x 1 root root 42584 2009-10-06 13:07 /usr/bin/[ -rwxr-xr-x 1

Re: .sh check for numeric content

2010-06-24 Thread Thomas Keusch
On Thu, Jun 24, 2010 at 11:58:05AM +0100, RW wrote: On Thu, 24 Jun 2010 05:19:53 +0200 Thomas Keusch f...@bsd-solutions-duesseldorf.de wrote: t...@eternity:~$ b=5 t...@eternity:~$ case $b in [0-9] ) echo numeric ;; * ) echo alpha ;;

Re: .sh check for numeric content

2010-06-24 Thread RW
On Thu, 24 Jun 2010 13:50:14 +0200 Thomas Keusch f...@bsd-solutions-duesseldorf.de wrote: 10 is not valid input according to the problem/pseudocode (in the forum) that the above code was posted as a solution for. And if you were answering in that forum that would be a good point.

Re: .sh check for numeric content

2010-06-24 Thread Chip Camden
On Jun 24 05:08, Jerry wrote: On Wed, 23 Jun 2010 23:32:57 -0400 (EDT) Karl Vogel vogelke+u...@pobox.com articulated: On Thu, 24 Jun 2010 09:24:39 +0800, Aiza aiz...@comclark.com said: A Receiving a variable from the command line that is suppose to A contain numeric values.

Re: .sh check for numeric content

2010-06-24 Thread Jerry
On Thu, 24 Jun 2010 09:14:39 -0700 Chip Camden sterl...@camdensoftware.com articulated: [snip] That [[:digit:]] pattern only works if your shell supports POSIX character classes in the case statement. I use Bash myself. I am not sure what other shells support this context. In any case, I

Re: .sh check for numeric content

2010-06-24 Thread Carl Johnson
vogelke+u...@pobox.com (Karl Vogel) writes: On Thu, 24 Jun 2010 09:24:39 +0800, Aiza aiz...@comclark.com said: A Receiving a variable from the command line that is suppose to contain A numeric values. How do I code a test to verify the content is numeric? The script below will work

Re: .sh check for numeric content

2010-06-24 Thread Carl Johnson
Carl Johnson ca...@peak.org writes: vogelke+u...@pobox.com (Karl Vogel) writes: On Thu, 24 Jun 2010 09:24:39 +0800, Aiza aiz...@comclark.com said: A Receiving a variable from the command line that is suppose to contain A numeric values. How do I code a test to verify the content is

Re: .sh check for numeric content

2010-06-24 Thread Carl Johnson
Carl Johnson ca...@peak.org writes: Carl Johnson ca...@peak.org writes: vogelke+u...@pobox.com (Karl Vogel) writes: On Thu, 24 Jun 2010 09:24:39 +0800, Aiza aiz...@comclark.com said: A Receiving a variable from the command line that is suppose to contain A numeric values. How do I code

Re: .sh check for numeric content

2010-06-24 Thread Aiza
Jerry wrote: On Thu, 24 Jun 2010 09:14:39 -0700 Chip Camden sterl...@camdensoftware.com articulated: [snip] That [[:digit:]] pattern only works if your shell supports POSIX character classes in the case statement. I use Bash myself. I am not sure what other shells support this context. In

Re: .sh check for numeric content

2010-06-24 Thread Jerry
On Fri, 25 Jun 2010 05:17:17 +0800 Aiza aiz...@comclark.com articulated: Jerry wrote: On Thu, 24 Jun 2010 09:14:39 -0700 Chip Camden sterl...@camdensoftware.com articulated: [snip] That [[:digit:]] pattern only works if your shell supports POSIX character classes in the case

Re: .sh check for numeric content

2010-06-24 Thread Chad Perrin
On Thu, Jun 24, 2010 at 05:51:20PM -0400, Jerry wrote: In any case, as I previously posted, it was left up to the OP to decide if the proposed solution was suitable for their needs. After reading all of the babble concerning what should be a relatively easy operation, perhaps the OP might

.sh check for numeric content

2010-06-23 Thread Aiza
Receiving a variable from the command line that is suppose to contain numeric values. How do I code a test to verify the content is numeric? Thanks for for help. ___ freebsd-questions@freebsd.org mailing list

Re: .sh check for numeric content

2010-06-23 Thread Thomas
On Thu, Jun 24, 2010 at 09:24:39AM +0800, Aiza wrote: Hello, Receiving a variable from the command line that is suppose to contain numeric values. How do I code a test to verify the content is numeric? http://www.google.com/search?q=shell+test+if+variable+numeric First link =

Re: .sh check for numeric content

2010-06-23 Thread Anh Ky Huynh
On Thu, 24 Jun 2010 09:24:39 +0800 Aiza aiz...@comclark.com wrote: Receiving a variable from the command line that is suppose to contain numeric values. How do I code a test to verify the content is numeric? echo $your_variable | grep -E ^[0-9]+(\.[0-9]*)*[0-9]+$ If $your_variable is

Re: .sh check for numeric content

2010-06-23 Thread RW
On Thu, 24 Jun 2010 03:37:55 +0200 Thomas f...@gothschlampen.com wrote: On Thu, Jun 24, 2010 at 09:24:39AM +0800, Aiza wrote: Hello, Receiving a variable from the command line that is suppose to contain numeric values. How do I code a test to verify the content is numeric?

Re: .sh check for numeric content

2010-06-23 Thread Aiza
Thomas wrote: On Thu, Jun 24, 2010 at 09:24:39AM +0800, Aiza wrote: Hello, Receiving a variable from the command line that is suppose to contain numeric values. How do I code a test to verify the content is numeric? http://www.google.com/search?q=shell+test+if+variable+numeric First link

Re: .sh check for numeric content

2010-06-23 Thread Thomas Keusch
On Thu, Jun 24, 2010 at 03:44:34AM +0100, RW wrote: Hello, On Thu, 24 Jun 2010 03:37:55 +0200 Thomas f...@gothschlampen.com wrote: On Thu, Jun 24, 2010 at 09:24:39AM +0800, Aiza wrote: Hello, Receiving a variable from the command line that is suppose to contain numeric

Re: .sh check for numeric content

2010-06-23 Thread Karl Vogel
On Thu, 24 Jun 2010 09:24:39 +0800, Aiza aiz...@comclark.com said: A Receiving a variable from the command line that is suppose to contain A numeric values. How do I code a test to verify the content is numeric? The script below will work with the Bourne or Korn shell. Results for 0 1

Re: .sh check for numeric content

2010-06-23 Thread Aiza
Aiza wrote: Thomas wrote: On Thu, Jun 24, 2010 at 09:24:39AM +0800, Aiza wrote: Hello, Receiving a variable from the command line that is suppose to contain numeric values. How do I code a test to verify the content is numeric?

Re: .sh check for numeric content

2010-06-23 Thread Giorgos Keramidas
On Thu, 24 Jun 2010 05:19:53 +0200, Thomas Keusch f...@bsd-solutions-duesseldorf.de wrote: t...@eternity:~$ b=5 t...@eternity:~$ case $b in [0-9] ) echo numeric ;; * ) echo alpha ;; esac numeric t...@eternity:~$ Works for me. Depending on what numeric