33.7 ed/ex Batch Edits: Avoid Errors When No MatchQ: My Bourne shell script ( 44.1 ) calls ed to edit a set of files: Q:
Q: It works fine except when one of the files does not contain pat1 . ed doesn't update that file, even though it could have matched pat2 . The other files are edited as they should be.
A:
On an error - including "no matches" -
ed
attempts to
discard any unread commands. If you are running
ed
"by hand"
this has no effect, but if its input is from a file, this makes
EOF -d-of-file) the next thing it sees. You could remove the
There is a simple workaround. Unlike the
ed - $i << end g/pat1/s//$site/g g/pat2/s//$cmty/g w end
The
-
(dash) flag suppresses the two numbers
that
ed
normally prints when reading and writing files.
These are the number of characters in the file,
and are usually irrelevant.
[As Chris explained, the - in comp.unix.questions on Usenet, 16 May 1989 |
|