Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!uwvax!tank!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.unix.questions Subject: Re: ed & redirected input Message-ID: <17520@mimsy.UUCP> Date: 16 May 89 01:00:47 GMT References: <9700003@osiris.cso.uiuc.edu> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 29 In article <9700003@osiris.cso.uiuc.edu> funk@osiris.cso.uiuc.edu writes: [the important lines ...] >ed $i <1,\$ s/pat1/$site/g >1,\$ s/pat2/$cmty/g >w >q >honker >It works like a champ EXCEPT if one of the files (say file2) does NOT contain >an occurrence of pat1. ... > HOWCUM???? On an error (such as `no matches') ed discards pending input, making EOF the next thing it sees. (You could remove the `q' command and you would see the same behaviour.) There is a simple work-around: ed - $i << end g/pat1/s//$site/g g/pat2/s//$cmty/g w end (the `-' suppresses the two number-of-characters reports). -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris