Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!sunybcs!boulder!skwu From: skwu@boulder.Colorado.EDU (WU SHI-KUEI) Newsgroups: comp.unix.questions Subject: Re: Patching multiple files with same text Message-ID: <19006@boulder.Colorado.EDU> Date: 29 Mar 90 23:43:28 GMT References: <193@rdb1.UUCP> <7592@jpl-devvax.JPL.NASA.GOV> Sender: news@boulder.Colorado.EDU Reply-To: skwu@boulder.Colorado.EDU (WU SHI-KUEI) Organization: University of Colorado, Boulder Lines: 14 '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.