Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Awk > Re: Return just...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 7 Topic 2059 of 2378
Post > Topic >>

Re: Return just the text I want from "uptime"

by gazelle@[EMAIL PROTECTED] (Kenny McCormack) Nov 5, 2007 at 02:15 PM

In article <1194269755.937838.186160@[EMAIL PROTECTED]
>,
Eliot  <ebp@[EMAIL PROTECTED]
> wrote:
>I want to use the system command "uptime" and then use awk to display
>just the text I am interested in:-
>Consider the following three lines of input
> 18:01:04 up 1 min,  0 users,  load average: 0.55, 0.28, 0.10
> 22:14:47 up  1:01,  0 users,  load average: 0.21, 0.05, 0.02
> 17:58:52 up 1 day,  2:34,  0 users,  load average: 0.02, 0.02, 0.00
>The output for each line should be
>1 min
>1:01
>1 day,  2:34
>Of course I only need to send one line at a time to awk, I am
>struggling because the number of fields varies.

Assuming you are running under Linux (a leap, yes, but probably a pretty
good bet), let me say that I tried this once and although seemingly
simple, it gets ugly after a while.  Instead, I ended up parsing
/proc/uptime directly (which is actually not that hard, once you get
over the initial idea).

This is assuming that you actually want to *do* something with the
uptime (I.e., parse it into some kind of actual time representation),
not just display it.
 




 7 Posts in Topic:
Return just the text I want from "uptime"
Eliot <ebp@[EMAIL PROT  2007-11-05 05:35:55 
Re: Return just the text I want from "uptime"
Janis Papanagnou <Jani  2007-11-05 14:41:12 
Re: Return just the text I want from "uptime"
Eliot <ebp@[EMAIL PROT  2007-11-05 05:46:16 
Re: Return just the text I want from "uptime"
gazelle@[EMAIL PROTECTED]  2007-11-05 14:15:45 
Re: Return just the text I want from "uptime"
ptjm@[EMAIL PROTECTED] (  2007-11-06 02:34:14 
Re: Return just the text I want from "uptime"
Janis Papanagnou <Jani  2007-11-06 04:48:02 
Re: Return just the text I want from "uptime"
Claudio <claudio@[EMAI  2007-11-09 18:22:44 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Oct 14 11:22:58 CDT 2008.