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 6 of 7 Topic 2059 of 2341
Post > Topic >>

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

by Janis Papanagnou <Janis_Papanagnou@[EMAIL PROTECTED] > Nov 6, 2007 at 04:48 AM

Patrick TJ McPhee wrote:
> 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
> 
>  BEGIN { FS="up |," }
>  { print $2 }
> 
> 

That doesn't cover the OPs requirements (see output line 3).
The FS must be refined, e.g.

   BEGIN { FS="up +|, *[0-9]+ users" }
   { print $2 }


Janis
 




 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 Wed Aug 27 17:40:51 CDT 2008.