Re: awk global replacement only after keyword

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Fri, Mar 26, 2010 at 7:28 AM,  <m.roth@xxxxxxxxx> wrote:
>>>or do you mean
>>>blah, blah
>>>blah, blah
>>>yadda, yadda, keyword,
>>>to-be-replaced
>>>also-to-be-replaced?
>>
>> Yup, the keyword marks the position where I then start looking
>> for matches. Once I get to work, I will give these a try.
>>
>> Thanks guys!
>
> Sure. And what you want is just
> { if ($0 ~ /keyword/ ) {
>     start = 1;
>  }
>  if ( start == 1 ) {
>     sub( str, repl );
>     print $0;
>  }
> }
>

That will start the replacements on the same line that the keyword is found.

mhr
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos


[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux