On 16:37 11 Feb 2003, Robert Tinsley <[EMAIL PROTECTED]> wrote:
| On Tue, 2003-02-11 at 16:31, Anthony E. Greene wrote:
| > How about a case statement:
| > case $var in
| > 1234567890)
|
| i think you mean
| 1|2|3|4|5|6|7|8|9|0)
Or just:
case $var in
[0-9])
This works fine if you know the range of the numbers and they're small
(eg <1000), otherwise you end up doing this:
case $var in
[0-9]|[1-9][0-9]|[1-9][0-9][0-9]|......... )
which gets pretty messy. The other thing you can do is invert the test:
case $var in
''|*[^0-9]*) not a number ... ;;
*) must be a number ... ;;
esac
In any case, usings case is MUCH faster and more efficient than the
grep-based methods, since it's built into the shell and needs no
subprocesses. And to my mind it's easier to read, too.
Cheers,
--
Cameron Simpson, DoD#743 [EMAIL PROTECTED] http://www.zip.com.au/~cs/
So there I was, snuggled in the leather seat of my brand new Ferrari I had
the oiled wooden gear shift in one hand, and the leather wrapped Momo in the
other. And, I had the stereo cranking _Born to be Wild_...
Only two problems, I was upside down, and under six feet of water...
--
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/redhat-list