From owner-freebsd-questions@FreeBSD.ORG Thu Aug 14 09:08:32 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 AB64937B401 for ; Thu, 14 Aug 2003 09:08:32 -0700 (PDT) Received: from remt26.cluster1.charter.net (remt26.cluster1.charter.net [209.225.8.36]) by mx1.FreeBSD.org (Postfix) with ESMTP id 061A643FE5 for ; Thu, 14 Aug 2003 09:08:32 -0700 (PDT) (envelope-from chowse@charter.net) Received: from [66.168.145.25] (HELO moe) by remt26.cluster1.charter.net (CommuniGate Pro SMTP 4.0.6) with ESMTP id 119270385 for freebsd-questions@freebsd.org; Thu, 14 Aug 2003 12:08:30 -0400 From: "Charles Howse" To: Date: Thu, 14 Aug 2003 11:08:21 -0500 Message-ID: <001a01c3627e$487d7a10$04fea8c0@moe> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2616 In-Reply-To: <20030814154920.GA74582@users.munk.nu> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Importance: Normal 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 16:08:33 -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` Hi Jez, thanks for the reply! As my daughter would say, "Well, DUHHHHHHH!" That worked fine, it reported 0 seconds. Can I refine it to give me something like: .784 seconds?