[CentOS] awk global replacement only after keyword
m.roth at 5-cent.us
m.roth at 5-cent.us
Fri Mar 26 14:28:57 UTC 2010
>>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;
}
}
mark
More information about the CentOS
mailing list