From owner-freebsd-questions@FreeBSD.ORG Sun May 4 19:00:10 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 65EDC37B401 for ; Sun, 4 May 2003 19:00:10 -0700 (PDT) Received: from thalia.otenet.gr (mailsrv.otenet.gr [195.170.0.5]) by mx1.FreeBSD.org (Postfix) with ESMTP id E1DAD43FB1 for ; Sun, 4 May 2003 19:00:08 -0700 (PDT) (envelope-from keramida@ceid.upatras.gr) Received: from gothmog.gr (patr530-a009.otenet.gr [212.205.215.9]) by thalia.otenet.gr (8.12.9/8.12.9) with ESMTP id h45205mX013275; Mon, 5 May 2003 05:00:06 +0300 (EEST) Received: from gothmog.gr (gothmog [127.0.0.1]) by gothmog.gr (8.12.9/8.12.9) with ESMTP id h452040X075725; Mon, 5 May 2003 05:00:04 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from giorgos@localhost) by gothmog.gr (8.12.9/8.12.9/Submit) id h45203A7075648; Mon, 5 May 2003 05:00:03 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Date: Mon, 5 May 2003 05:00:03 +0300 From: Giorgos Keramidas To: Peter Leftwich Message-ID: <20030505020003.GB24519@gothmog.gr> References: <20030504180640.E99631-100000@Www.Video2Video.Com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030504180640.E99631-100000@Www.Video2Video.Com> cc: SDBug@SDBug.Org cc: FreeBSD-Questions@freebsd.org Subject: Re: customize the uptime command 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: Mon, 05 May 2003 02:00:10 -0000 On 2003-05-04 18:11, Peter Leftwich wrote: > $ uptime > 6:06PM up 15 days, 21:12, 1 user, load averages: 0.06, 0.13, 0.08 > > I wonder if it is possible to rewrite the uptime command, similar to the > way you can customize the output of "date" using +%H%M etc... > > The reason I ask is that I'd prefer a flag to standardize the format to > y:m:d:H:M;S or years, months, days, hours, minutes, seconds. Or you could > have some kind of "--only H" flag which would display the uptime ONLY has > hours. In my case, the example above, it would be: 381 hours > > Is there a fast script out there can reformat the uptime perhaps?? You can always do fancy reformatting of text with awk: uptime | awk '{ if (match($0, "days,")) { today = $5; sub(":.*$", "", today); hours = 24 * $3 + today; sub("[0-9]* days,[^,]*,", hours" hours,"); } else { today=$3; sub(":.*$", "", today); sub("up [^,]*,", "up "today" hours,"); } print; }' The above should work for both types of uptime output. - Giorgos