From owner-freebsd-questions@FreeBSD.ORG Fri Aug 12 02:52:30 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EB36F16A428 for ; Fri, 12 Aug 2005 02:52:30 +0000 (GMT) (envelope-from Qiang.Xu@fujixerox.com) Received: from mx20.fujixerox.co.jp (mx20.fujixerox.co.jp [192.26.96.20]) by mx1.FreeBSD.org (Postfix) with ESMTP id 25D7743D46 for ; Fri, 12 Aug 2005 02:52:29 +0000 (GMT) (envelope-from Qiang.Xu@fujixerox.com) Received: from isvw20.fujixerox.co.jp ([129.249.27.140]) by mx20.fujixerox.co.jp with ESMTP id j7C2qL1l018178; Fri, 12 Aug 2005 11:52:21 +0900 (JST) Received: from ms20.fujixerox.co.jp (localhost [127.0.0.1]) by isvw20.fujixerox.co.jp with ESMTP id j7C2qLOB013621; Fri, 12 Aug 2005 11:52:21 +0900 (JST) Received: from sgpaphq-smtp01.fujixerox.com ([13.198.8.73]) by ms20.fujixerox.co.jp with ESMTP id j7BD9aHl014619; Fri, 12 Aug 2005 11:52:20 +0900 (JST) Received: from mailhost.sgp.fujixerox.com by sgpaphq-smtp01.fujixerox.com with ESMTP id 116249901123815089; Fri, 12 Aug 2005 10:51:29 +0800 Received: from localhost (localhost [127.0.0.1]) by localhost.sgp.fujixerox.com (Postfix) with SMTP id 0333B1D99F; Fri, 12 Aug 2005 10:51:25 +0800 (SGT) Received: from sess.xssc.sgp.xerox.com (unknown [13.198.33.122]) by imss.sgp.fujixerox.com (Postfix) with ESMTP id CB2561D93C; Fri, 12 Aug 2005 10:51:15 +0800 (SGT) From: Xu Qiang To: dpk , Xu Qiang Date: Fri, 12 Aug 2005 10:54:49 +0800 X-Sent-Folder-Path: Sent Items X-Mailer: Oracle Connector for Outlook 9.0.4 60130 (9.0.2711) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Message-Id: <20050812025115.CB2561D93C@imss.sgp.fujixerox.com> Cc: freebsd-questions@freebsd.org Subject: RE: Help on bash script? 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: Fri, 12 Aug 2005 02:52:31 -0000 dpk wrote: > On Fri, 12 Aug 2005, Xu Qiang wrote: >> 1. The way of incrementing the variable NCOREFILES. Why does it use >> the formula of "NCOREFILES=3D$[ $NCOREFILES + 1 ]", and not the direct >> way of "NCOREFILES=3D$NCOREFILES+1"? > = > If that was done, NCOREFILES would end up looking like: > = > +1+1+1+1+1+1+1 > = > as bash does not automatically differentiate between numeric and > string variables. What the funky looking construct does is convince > bash to treat it as a numeric/arithmetic expression. Strangely, there is no mention of this assignment usage in the book "Learni= ng the bash shell, 2nd ed" by O'Reilly at my hand. :( And "man bash" didn't talk of it either. However, it mentioned for arithmet= ic evaluation, we can use = id++ id-- variable post-increment and post-decrement ++id --id variable pre-increment and pre-decrement If it is correct, then I can also increment NCOREFILES by: = ++NCOREFILES. = But I doubt it... Regards, Xu Qiang