People use the
editor with script files to make global edits.
But many versions of
can't edit large files. The
editor is usually better, but it has limits, too. How large is
"large"? That depends on your version. Most
s I've seen
can't handle more than about 100,000 characters.
There are no limits on
although you'll need to
save its output somehow (
and your editing script may
have to be changed to work with
Here's what you'll see when
ed - words < edscr
's verbose way of telling you that
something's wrong. This obscure message is especially bad if you
write a shell script that edits multiple files in a loop; you may not
notice the error or be able to tell which file had the problem. Be
sure your script checks for errors!
Unfortunately for programmers,
may not return an error status
that you can test.
though. When the
command succeeds, it doesn't display
anything. The simplest way to find errors is to check for any output
. This chunk of a Bourne shell script
shows how (your filename is in the
edout="`ed - $filename < edscr 2>&1`"
if [ -n "$edout" -o $? -ne 0 ]
echo "$edout" 1>&2
echo "QUITTING: 'ed - $filename < edscr' bombed?!?" 1>&2