Re: .sh check for numeric content

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

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 migh

Re: .sh check for numeric content

2010-06-24 Thread Jerry
On Fri, 25 Jun 2010 05:17:17 +0800 Aiza articulated: > Jerry wrote: > > On Thu, 24 Jun 2010 09:14:39 -0700 > > Chip Camden articulated: > > > > [snip] > > > >> That [[:digit:]] pattern only works if your shell supports POSIX > >> character classes in the case statement. > > > > I use Bash mys

Re: .sh check for numeric content

2010-06-24 Thread Aiza
Jerry wrote: On Thu, 24 Jun 2010 09:14:39 -0700 Chip Camden 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 simply supplied a

Re: .sh check for numeric content

2010-06-24 Thread Carl Johnson
Carl Johnson writes: > Carl Johnson writes: > >> vogelke+u...@pobox.com (Karl Vogel) writes: >> > On Thu, 24 Jun 2010 09:24:39 +0800, > Aiza 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

Re: .sh check for numeric content

2010-06-24 Thread Carl Johnson
Carl Johnson writes: > vogelke+u...@pobox.com (Karl Vogel) writes: > On Thu, 24 Jun 2010 09:24:39 +0800, Aiza 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

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 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

Re: .sh check for numeric content

2010-06-24 Thread Jerry
On Thu, 24 Jun 2010 09:14:39 -0700 Chip Camden 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 simply supplied a possible sol

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 articulated: > > > > >> On Thu, 24 Jun 2010 09:24:39 +0800, > > >> Aiza said: > > > > A> Receiving a variable from the command line that is suppose to > > A> contain numeric values. How do I code a test to

Re: .sh check for numeric content

2010-06-24 Thread RW
On Thu, 24 Jun 2010 13:50:14 +0200 Thomas Keusch 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. > Spoonfeeding solutions to trivial (and

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 wrote: > > > t...@eternity:~$ b=5 > > t...@eternity:~$ case "$b" in > > > [0-9] ) > > > echo numeric > > > ;; > > > * ) > > > echo alpha > > > ;; > > > esa

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

Re: .sh check for numeric content

2010-06-24 Thread RW
On Thu, 24 Jun 2010 05:19:53 +0200 Thomas Keusch 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 with 10.

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 s

Re: .sh check for numeric content

2010-06-24 Thread Jerry
On Wed, 23 Jun 2010 23:32:57 -0400 (EDT) Karl Vogel articulated: > >> On Thu, 24 Jun 2010 09:24:39 +0800, > >> Aiza 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> content is numeric? > >The

Re: .sh check for numeric content

2010-06-23 Thread Giorgos Keramidas
On Thu, 24 Jun 2010 05:19:53 +0200, Thomas Keusch 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" means, th

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? http://www.google.com/search?q=shell+test+if+variable+numeric

Re: .sh check for numeric content

2010-06-23 Thread Karl Vogel
>> On Thu, 24 Jun 2010 09:24:39 +0800, >> Aiza 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 12 1234 .12 1

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 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. > >

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 RW
On Thu, 24 Jun 2010 03:37:55 +0200 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.go

Re: .sh check for numeric content

2010-06-23 Thread Anh Ky Huynh
On Thu, 24 Jun 2010 09:24:39 +0800 Aiza 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 numeric (123, or

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 => http://

.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 http://lists.freebsd.org/mailman/listinfo/