Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!ubvax!mrspoc!itkin From: itkin@mrspoc.UUCP (Steven M. List) Newsgroups: comp.unix.questions Subject: Re: ed & redirected input Message-ID: <7652@mrspoc.UUCP> Date: 16 May 89 19:58:20 GMT References: <9700003@osiris.cso.uiuc.edu> Reply-To: itkin@mrspoc (Steven List) Organization: Transact Software, Inc., Mt. View, CA Lines: 35 In article <9700003@osiris.cso.uiuc.edu> funk@osiris.cso.uiuc.edu writes: > ed $i < 1,\$ s/pat1/$site/g > 1,\$ s/pat2/$cmty/g > w > q > > 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, (and it complains about not having seen a "w"), with the effect that the > file is NOT updated, even though it should have worked for the occurrences > of pat2. All other files are correctly updated, as they contain occurrences > of both pat1 and pat2. If I do it by hand, ed of course complains about the > no match, but still processes any subsequent commands. > I'm not sure if this is EXACTLY your problem, but I've run into this before. The problem is that ED doesn't like "1,$s/x/y/" if there are no "x" strings in the file. The cleaner way to do this, when you want to perform these operations across the whole file is to use the global command: ed $i <~ : Chairman, Unify User Group of Northern California : {apple,coherent,limbo,mips,pyramid,ubvax}!mrspoc!itkin : Voice: (415) 961-6112