Date: Sat, 24 May 2003 11:15:20 -0700 From: Joshua Oreman <oremanj@webserver.get-linux.org> To: lbland <lbland@vvi.com> Cc: questions@freebsd.org Subject: Re: editing uptime output with sed? Message-ID: <20030524181519.GA55980@webserver.get-linux.org> In-Reply-To: <71D66F70-8E10-11D7-A088-0030659A531A@vvi.com> References: <71D66F70-8E10-11D7-A088-0030659A531A@vvi.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030524181519.GA55980>