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 > Need a new solu...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 4 Topic 2111 of 2297
Post > Topic >>

Need a new solution for awk problem

by mcbalagtas@[EMAIL PROTECTED] Dec 21, 2007 at 04:15 PM

Ok after searching, I figured out I can't use a variable in a pattern
search in awk. But it hard for me to give it up since it works so
cleanly. The awk statement below gives me the exact output I need.
Except for the fact it won't let me change the the pattern for $2.

Basically, I need to start/stop all devices on the same NET $2
identified by $6. I used uniq because the restart/stop command only
needs device number and it will restart all the ****ts in that NET.

I looked at the other replies and couldn't figure out how to make
'grep' work in this situation.

Can anyone suggest another solution path? I'm not looking specifically
for an awk solution.

awk  '($2 ~/-NET=3/) && ($5 ~ /-SYC/) { print $6 ; }' CONFIG.CFG >
sort.tmp
input=`uniq
sort.tmp`
echo $input

results:
459 106 107 108 109 110

Example of CONFIG.CFG's format

  socket12101   -NET=1  -CRYPT=0        -TIMEOUT=0      -MCW    103
  socket12102   -NET=1  -CRYPT=0        -TIMEOUT=0      -SYC     103
  socket12103   -NET=1  -CRYPT=0        -TIMEOUT=0      -SYC     111
  socket12114   -NET=3  -CRYPT=0        -TIMEOUT=0      -MCW    459
  socket12104   -NET=3  -CRYPT=0        -TIMEOUT=0      -SYC     459
  socket12105   -NET=3  -CRYPT=0        -TIMEOUT=0      -SYC     106
  socket12106   -NET=3  -CRYPT=0        -TIMEOUT=0      -SYC     107
  socket12107   -NET=3  -CRYPT=0        -TIMEOUT=0      -SYC     107
 .....
 




 4 Posts in Topic:
Need a new solution for awk problem
mcbalagtas@[EMAIL PROTECT  2007-12-21 16:15:40 
Re: Need a new solution for awk problem
Janis Papanagnou <Jani  2007-12-22 01:37:51 
Re: Need a new solution for awk problem
Bill Marcum <marcumbil  2007-12-22 13:40:56 
Re: Need a new solution for awk problem
gazelle@[EMAIL PROTECTED]  2007-12-22 21:15:18 

Post A Reply:
  Go here to Signup

AddThis Feed Button


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

Contact
tan12V112 Sun Jul 6 20:39:49 CDT 2008.