.sh check for numeric content
Thomas
fwd at gothschlampen.com
Thu Jun 24 10:31:36 UTC 2010
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 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 root root 30284 2009-10-06 13:07 /usr/bin/test
(this actually is from a Linux system)
You can read about the checks test(1) can perform and its syntax in its
manual page. It will give you a nice and concise overview of what can be
archived in this "[ $EXPRESSION ]" syntax, and what checks are left to
be performed in other ways. Hope this helps.
Regards,
Thomas
More information about the freebsd-questions
mailing list