[CentOS] awk global replacement only after keyword

m.roth at 5-cent.us m.roth at 5-cent.us
Fri Mar 26 14:31:48 UTC 2010

> Trying to avoid a perl script which wouldn't be hard, but I am looking
> for an awk one liner that does a replacement, but only after it sees a
> key word on some line.
> Anyone know of that's easy to do?

{if ( $0 ~ /<keyword>/) (sub(str, repl);} print $0;}


More information about the CentOS mailing list