On 2007-11-05, 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.
>
uptime | awk -F"up" '{print $2}' | awk -F",[^,]*users" '{print $1}'
Consider the use of "sed" instead.
Best regards,
Claudio.


|