Talk About Network



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: search for ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 8 of 13 Topic 2229 of 2236
Post > Topic >>

Re: search for charater "="

by Ed Morton <morton@[EMAIL PROTECTED] > May 5, 2008 at 08:54 AM

On 5/5/2008 8:46 AM, pk wrote:
> On Monday 5 May 2008 15:25, Ed Morton wrote:
> 
> 
>>awk 'BEGIN{split("5 8 10",t);for(i in t)skip[t[i]]} !(NR in skip)' file
> 
> 
> So why not do just
> 
> awk 'BEGIN{skip[5];skip[8];skip[10]} !(NR in skip)' file
> 
> and avoid the extra array?
> 

because it's not reasonably scalable:

awk 'BEGIN{skip[5];skip[8];skip[10];skip[12];skip[15];skp[17];skip[21]}
!(NR in
skip)' file

vs:

awk 'BEGIN{split("5 8 10 12 15 17 21",t);for(i in t)skip[t[i]]} !(NR in
skip)' file

is open to typos (e.g. mistyping skp vs skip as I did in one spot above)
and it
doesn't let you just pass in a list of lines to skip:

awk -v lines="5 8 10 12 15 17 21" 'BEGIN{split(lines,t);for(i in
t)skip[t[i]]}
!(NR in skip)' file

Regards,

	Ed.




 13 Posts in Topic:
search for charater "="
Nezhate <mazouz.nezhat  2008-05-05 00:31:15 
Re: search for charater "="
pk <pk@[EMAIL PROTECTE  2008-05-05 09:49:23 
Re: search for charater "="
Nezhate <mazouz.nezhat  2008-05-05 01:58:02 
Re: search for charater "="
pk <pk@[EMAIL PROTECTE  2008-05-05 11:11:28 
Re: search for charater "="
Ed Morton <morton@[EMA  2008-05-05 08:21:02 
Re: search for charater "="
Ed Morton <morton@[EMA  2008-05-05 08:25:51 
Re: search for charater "="
pk <pk@[EMAIL PROTECTE  2008-05-05 15:46:30 
Re: search for charater "="
Ed Morton <morton@[EMA  2008-05-05 08:54:00 
Re: search for charater "="
gazelle@[EMAIL PROTECTED]  2008-05-05 13:56:33 
Re: search for charater "="
Ed Morton <morton@[EMA  2008-05-05 09:26:17 
Re: search for charater "="
"Rajan" <rsh  2008-05-05 22:33:48 
Re: search for charater "="
Janis <janis_papanagno  2008-05-05 02:14:53 
Re: search for charater "="
Ed Morton <morton@[EMA  2008-05-05 08:17:13 

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 May 15 23:55:03 CDT 2008.