People use the ed
editor with script files to make global edits.
But many versions of ed
can't edit large files. The ex
editor is usually better, but it has limits, too. How large is
"large"? That depends on your version. Most ed
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 (34.3
and your editing script may
have to be changed to work with sed
Here's what you'll see when ed
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, ed
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