Useful ex Commands

Many line editor commands are not particularly useful in scripts. The two commands that you will use far and away the most often are s (substitute), to replace one pattern with another, and d (delete) to delete one or more lines. On occasion, though, you'll want to insert text from a script. (Editing scripts built by diff () make heavy use of insert, append, delete, and change commands.) And of course, you need commands to write and quit the editor.

Here's the syntax of most of the commands you may encounter in ex editing scripts. (The ed editor understands the abbreviated versions of some, but not all of, these commands.) Elements in [brackets] are optional; don't type the [ or ]. (The leading colon is the ex command character used to issue an ex command from vi; in a script, the colon would be omitted.)

- TOR, DG