From owner-freebsd-questions@FreeBSD.ORG Thu Jun 24 10:31:36 2010 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BAA38106566B for ; Thu, 24 Jun 2010 10:31:36 +0000 (UTC) (envelope-from fwd@gothschlampen.com) Received: from vs.gothschlampen.com (vs.gothschlampen.com [85.93.11.85]) by mx1.freebsd.org (Postfix) with ESMTP id 815918FC0A for ; Thu, 24 Jun 2010 10:31:36 +0000 (UTC) Received: by vs.gothschlampen.com (Postfix, from userid 667) id EB7331F6B7E; Thu, 24 Jun 2010 12:31:13 +0200 (CEST) Date: Thu, 24 Jun 2010 12:31:13 +0200 From: Thomas To: Aiza Message-ID: <20100624103113.GA27123@gothschlampen.com> References: <4C22B3D7.6070102@comclark.com> <20100624013755.GA5009@gothschlampen.com> <4C22C816.3000105@comclark.com> <4C22E4A0.1040206@comclark.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4C22E4A0.1040206@comclark.com> User-Agent: Mutt/1.5.13 (2006-08-11) Cc: questions@freebsd.org Subject: Re: .sh check for numeric content X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Jun 2010 10:31:36 -0000 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