From owner-freebsd-questions@FreeBSD.ORG Thu Aug 14 08:49:22 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 2748B37B401 for ; Thu, 14 Aug 2003 08:49:22 -0700 (PDT) Received: from munk.nu (213-152-51-194.dsl.eclipse.net.uk [213.152.51.194]) by mx1.FreeBSD.org (Postfix) with ESMTP id 89F1543F85 for ; Thu, 14 Aug 2003 08:49:21 -0700 (PDT) (envelope-from munk@munk.nu) Received: from munk by munk.nu with local (Exim 4.20) id 19nKLp-000JRJ-0T for freebsd-questions@freebsd.org; Thu, 14 Aug 2003 16:49:21 +0100 Date: Thu, 14 Aug 2003 16:49:20 +0100 From: Jez Hancock To: freebsd-questions@freebsd.org Message-ID: <20030814154920.GA74582@users.munk.nu> Mail-Followup-To: freebsd-questions@freebsd.org References: <001201c3627b$44047c70$04fea8c0@moe> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <001201c3627b$44047c70$04fea8c0@moe> User-Agent: Mutt/1.4.1i Sender: User Munk 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 15:49:23 -0000 On Thu, Aug 14, 2003 at 10:46:45AM -0500, Charles Howse wrote: > Hello List, > > I've migrated from Redhat Linux 9 to FreeBSD 4.8-RELEASE, character mode > - no gui. > > I'm trying to calculate the number of seconds between $start_time and > $end_time in a bash script. > > Start_time=`date +%s` # Seconds past midnight at start of script > [ do lots of stuff ] > End_time=`date +%s` # Seconds past midnight at end of script > > Then I want to: et=`bc $end_time - $start_time` to get the number of > seconds or fractions of seconds elapsed. How about: et=`echo "$end_time - $start_time" | bc` -- Jez http://www.munk.nu/