ED_EXAMPLES(oh) LOCAL ED_EXAMPLES(oh) ed_examples - interactive edit, scripting and tips interactive_edit Commands G and V work the same as the lower case version, but edits each match interactively. 1. G/re/ 2. Returns the first match. 3. User edits the match. 4. ed displays the next match. 5. The user can edit the match or enter & to repeat the last non-empty command list. $ ed -p : :a line 1 line 2 line 3 . :G/l/ line 1 s/n/a/ line 2 s/e/o/ line 3 & :,n liae 1 lino 2 lino 3 shell_commands The following commands can be used with shell commands: e : edit output of command : e !command r : read output of command into buffer : [range]r !command w : write addressed lines into command. : [range]w !command $ ed -p : :e !ls :,n dir1 dir2 :r !ls dir1 :,n dir1 dir2 file1 :w !xargs -n1 echo dir1 dir2 file1 SPLIT_LINES $ ed t a hello bye . w 10 w !awk 'sub("o ","o\n",$0);' > % e 10 ,n hello bye SCRIPTING NOTE: It's important to always have the. and w on any interactive commands. To add a . on a script without ending the input, one option is to enter \. and then substitute the \ : ,s@^\\.$@.@ example $ ed script a a this line is appended \. w . ,s@^\\.$@.@ w q $ cat script a this line is appended . w $ cat test.txt line 1 $ ed - test.txt < script $ cat test.txt line 1 this line is appended TODO - Translate to Spanish. SEE ALSO ed(oh) links - Solene - ed split lines: https://dataswamp.org/~solene/2018-12-04-fun-splitting-line.html - Example ed (Comparing and Merging Files): https://www.gnu.org/software/diffutils/manual/html_node/Example-ed.html - ed Scripts (Comparing and Merging Files): https://www.gnu.org/software/diffutils/manual/html_node/ed-Scripts.html - unix.com - Ed command execution in script file: https://www.unix.com/shell-programming-and-scripting/233897-ed-command-execution-script-file.html HISTORY 2026-06-02 : Created. AUTHORS ohazot(oh) | about(oh) | ohazot.com: https://ohazot.com OpenBSD 7.9 2026-06-02 ED_EXAMPLES(oh)