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: Newbie ques...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 4 Topic 2121 of 2345
Post > Topic >>

Re: Newbie question on awk

by loki harfagr <loki@[EMAIL PROTECTED] > Jan 4, 2008 at 04:51 PM

On Fri, 04 Jan 2008 08:24:46 -0800, Zinger wrote:

> Hi All,
> 
> I want to be able to read the contents of a file as below:-
> 
> ==================================
> There are 4 occurrences
> 
> These occurrences are listed below:
> machine1---RUNNING
> machine2---STOPPED
> machine3---WORKING
> machine4---RUNNING
> 
> ==================================
> 
> I want the script to pick all the machines in RUNNING state i.e.
> machines1 and 4 and assign their names to a variable for further
> manipulation.
> 
> Do I use awk?

 Well, the real answer depends much on the rest of what you
expect to do overall, but just supposing you really want to
fill a variable with previous problem description, it's
possible to do for instance:

$ woooop=$(awk '$NF=="RUNNING"{print $1}' FS=- yourfile)

 or backticks instead of ba****sm:
$ woooop=`awk '$NF=="RUNNING"{print $1}' FS=- yourfile`


 then use your variable at your will:
$ echo ${woooop} 
machine1 machine4

$ echo "${woooop}"
machine1
machine4
 




 4 Posts in Topic:
Newbie question on awk
Zinger <zmasood@[EMAIL  2008-01-04 08:24:46 
Re: Newbie question on awk
loki harfagr <loki@[EM  2008-01-04 16:51:18 
Re: Newbie question on awk
Ed Morton <morton@[EMA  2008-01-04 11:03:23 
Re: Newbie question on awk
Ted Davis <tdavis@[EMA  2008-01-04 19:53:23 

Post A Reply:
  Go here to Signup

AddThis Feed Button


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

Contact
tan12V112 Thu Sep 4 23:57:53 CDT 2008.