Patching multiple files with same text

WU SHI-KUEI skwu at boulder.Colorado.EDU
Fri Mar 30 09:43:28 AEST 1990


'Ed' and a 'here' document will do what you need.  E.g:

for i in file1 file2 ......
do
ed $i << THE_END
g/RE_1/.,/RE_2/c\\
new text, with each new line escaped
w
.
THE_END
done

Where RE_1 (RE_2) matches the first (last) line of the text that must be
replaced.



More information about the Comp.unix.questions mailing list