Path: utzoo!attcan!uunet!auspex!guy From: guy@auspex.auspex.com (Guy Harris) Newsgroups: comp.unix.questions Subject: Re: ed & redirected input Message-ID: <1631@auspex.auspex.com> Date: 16 May 89 17:52:04 GMT References: <9700003@osiris.cso.uiuc.edu> Reply-To: guy@auspex.auspex.com (Guy Harris) Organization: Auspex Systems, Santa Clara Lines: 24 >It works like a champ EXCEPT if one of the files (say file2) does NOT contain >an occurrence of pat1. Then ed proceeds to ignore everything else except the >q, Yup. That's deliberate. A command of the form "1,$s/pat1/pat2/g" fails if it doesn't find at least one instance of "pat1"; if a command fails, "ed" assumes that the script isn't finding what it expects to find, and therefore blows the rest of the script off, under the assumption that you may not get the results you expect from the script.... >I finally gave up and resorted to using sed into a temp file and moving the >temp file back to the original file. But it still leaves me wondering > HOWCUM???? See above. If you want a "substitute" command of that sort that *doesn't* fail if it doesn't find any instances of the pattern, try g/pat1/s//pat2/g rather than 1,$s/pat1/pat2/g