How can I replace some words 1-5 lines after the matched line ?

Steven Shiau steven at nchc.org.tw
Tue Jan 20 10:29:56 UTC 2004


Hi!
I am trying to write a script to replace some words 1-5 lines after the
matched line. For example, here is some part in kernel-2.4.spec,
...
# Second, per-architecture exclusions (ifarch)
%ifarch i386
%define buildsmp 0
%define buildup 0
%endif
%ifarch i586
%define buildsmp 0
%endif
...
I am trying to match the "%ifarch i386", and then I would like to make
the "%define buildup" to be "1", also if the search match the "%ifarch
i586",  I would like to make the "%define buildsmp" to be 1. How can I
make it ?
If I use perl or sed, it can only replace the word in the matched line,
not the following lines. What's the better solution ?

Thanks in advance.
-- 
Steven Shiau






More information about the fedora-list mailing list