ed & redirected input
Chris Torek
chris at mimsy.UUCP
Tue May 16 11:00:47 AEST 1989
In article <9700003 at osiris.cso.uiuc.edu> funk at osiris.cso.uiuc.edu writes:
[the important lines ...]
>ed $i <<honker
>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 at mimsy.umd.edu Path: uunet!mimsy!chris
More information about the Comp.unix.questions
mailing list