From owner-freebsd-questions@FreeBSD.ORG Thu Aug 14 11:01:34 2003 Return-Path: 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 C3A5437B401 for ; Thu, 14 Aug 2003 11:01:34 -0700 (PDT) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id EC95D43FA3 for ; Thu, 14 Aug 2003 11:01:33 -0700 (PDT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.12.9/8.12.9) id h7EI1Qwb046882; Thu, 14 Aug 2003 13:01:26 -0500 (CDT) (envelope-from dan) Date: Thu, 14 Aug 2003 13:01:26 -0500 From: Dan Nelson To: Richard Tobin Message-ID: <20030814180126.GB33379@dan.emsphone.com> References: <200308141742.SAA17915@rhymer.cogsci.ed.ac.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200308141742.SAA17915@rhymer.cogsci.ed.ac.uk> X-OS: FreeBSD 5.1-CURRENT X-message-flag: Outlook Error User-Agent: Mutt/1.5.4i cc: Charles Howse cc: freebsd-questions@freebsd.org Subject: Re: Using bc in bash script X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Aug 2003 18:01:35 -0000 In the last episode (Aug 14), Richard Tobin said: > > I'm trying to calculate the number of seconds between $start_time and > > $end_time in a bash script. > > Bash has built-in integer arithmetic: > > et=$[End_time - Start_time] Most bourne-based shells have arithmetic evaluation. For portability, you should use the $(( )) syntax: /bin/sh $ echo $(( 1 + 3 )) 4 $ -- Dan Nelson dnelson@allantgroup.com