"Kenny McCormack" <gazelle@[EMAIL PROTECTED]
> wrote in message
news:fvn3mh$l72$1@[EMAIL PROTECTED]
> In article <481F09BE.9030703@[EMAIL PROTECTED]
>,
> Ed Morton <morton@[EMAIL PROTECTED]
> wrote:
>>On 5/5/2008 3:58 AM, Nezhate wrote:
>>> Thanks for your help.
>>> I have another question:
>>> how to delete en entire specified lines in file using awk
>>> , for example I want to delete the 5 th, 8 and 10 th line in file2 ?
>>
>>awk 'BEGIN{split("5 8 10",t);for(i in t)skip[t[i]]} !(NR in skip)' file
>>
>> Ed.
>>
>
> I was thinking along those lines, but it does seem a little bulky, not
> to mention that someone might point out that array lookups might be
> costly (not that any of us is likely to ever notice it in our
lifetimes).
>
> How about: NR ~ /^(5|8|10)$/
ITYM NR !~/^(5|8|10)$/ A nice one, I haven't used RE to match NR.
>
> Note that since this is a static RE, it will be compiled at compiletime,
> not at runtime, so it should be pretty efficient.
>


|