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.


|