From owner-freebsd-questions@FreeBSD.ORG Sat May 24 11:14:13 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 9ED7A37B401 for ; Sat, 24 May 2003 11:14:13 -0700 (PDT) Received: from adsl-64-161-78-226.dsl.lsan03.pacbell.net (adsl-64-161-78-226.dsl.lsan03.pacbell.net [64.161.78.226]) by mx1.FreeBSD.org (Postfix) with SMTP id B3D5343F75 for ; Sat, 24 May 2003 11:14:12 -0700 (PDT) (envelope-from oremanj@adsl-64-161-78-226.dsl.lsan03.pacbell.net) Received: (qmail 77801 invoked by uid 1001); 24 May 2003 18:15:20 -0000 Date: Sat, 24 May 2003 11:15:20 -0700 From: Joshua Oreman To: lbland Message-ID: <20030524181519.GA55980@webserver.get-linux.org> References: <71D66F70-8E10-11D7-A088-0030659A531A@vvi.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <71D66F70-8E10-11D7-A088-0030659A531A@vvi.com> User-Agent: Mutt/1.4i cc: questions@freebsd.org Subject: Re: editing uptime output with sed? 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: Sat, 24 May 2003 18:14:13 -0000 On Sat, May 24, 2003 at 01:52:11PM -0400 or thereabouts, lbland seemed to write: > hi- > > sorry for the generic question... > > how do I take uptime output: > 1:45PM up 6 days, 3:58, 11 users, load averages: 0.30, 0.24, 0.21 > and get the 2nd to last value with sed? (how do I get sed to output > 0.24 to stdout)? Uptime's output is one of the hardest things for a program/script to parse. Here's a load average command (for 5 mins; replace the \2 with \1 for 1 min. or \3 for 15 mins): uptime | sed -e 's/.*load average: \(.*\...\), \(.*\...\), \(.*\...\)/\2/' -e 's/ //g' And an uptime one: uptime | sed -e 's/.* \(.* days,\)\? \(.*:..,\) .*/\1 \2/' -e's/,//g' -e 's/ days/d/' -e 's/ up //' HTH, -- Josh PS: I didn't test these, I just found them on the Net. > > TIA- > > -lance > > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org"