make an editing script (
that you give to the
They'll apply your same edits to other copies of the same file.
This is handy if you have a lot of copies of a big file,
spread around a network or on a lot of disks, and you want to make the
same small change to all the files.
Instead of sending new copies of the whole file, just have
make a script - and use that little script to update all the big files.
Here's a demo.
I'm going to modify a program called
Then I'll use
to apply the same changes to
a copy of the file named
(which might be at a remote
cp pqs.c remote-pqs.c
cp pqs.c pqs.c.new
diff pqs.c pqs.c.new
< "%s: quitting: not able to %s your .pq_profile file.\n",
> fprintf(stderr, "%s: quitting: can't %s your .pq_profile file.\n",
diff -e pqs.c pqs.c.new > edscr
fprintf(stderr, "%s: quitting: can't %s your .pq_profile file.\n",
echo w >> edscr
ed remote-pqs.c < edscr
diff pqs.c.new remote-pqs.c
, I make the simulated "remote" copy of the
, I make another copy of it; at prompt
, I edit the copy.
that shows the changes I made.
Then, at prompt
, I run
I save the result in
, which I show at prompt 6.
is important because
doesn't add a
command to the script file.
to write its changes to the file.
to add the command.
, I give
the name of the "remote" file to edit as a
command-line argument and give it the script file on its standard input.
, I do a
that shows the changes have been made
and the two versions are the same.