.Dd 2026-06-02 .de oit .It \\$* .. .de obi .Bl -\\$1 -compact .shift .oit \\$* .. .de obe .obi \\$* .El .. .de obd .Bd -literal -compact \\$* .. .de obc .Bl -column \\$* .. .Dt ED_EXAMPLES oh .Os .Nm ed_examples .Nd interactive edit, scripting and tips .Ss interactive_edit Commands G and V work the same as the lower case version, but edits each match interactively. .Bl -enum -compact .It G/re/ .It Returns the first match. .It User edits the match. .It ed displays the next match. .It The user can edit the match or enter & to repeat the last non-empty command list. .El .obd $ 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 .Ed .Ss shell_commands The following commands can be used with shell commands: .obc o write_addressed_Lines_Into_command desc .It e Ta : edit output of command Ta : Li e !command .It r Ta : read output of command into buffer Ta : Li [range]r !command .It w Ta : write addressed lines into command. Ta : Li [range]w !command .El .obd $ ed -p : :e !ls :,n dir1 dir2 :r !ls dir1 :,n dir1 dir2 file1 :w !xargs -n1 echo dir1 dir2 file1 .Ed .Sh SPLIT_LINES .obd $ ed t a hello bye \&. w 10 w !awk 'sub("o ","o\en",$0);' > % e 10 ,n hello bye .Ed .Sh SCRIPTING .obc .Tg note .It NOTE: It's important to always have the . and w on any interactive commands. .It \ To add a \&. on a script without ending the input, one option is to enter \e\&. and then substitute the \e\ : .Li ,s@^\e\e\&.$@\&.@ .El .Ss example .obd $ ed script a a this line is appended \e\&. w \&. ,s@^\e\e\&.$@\&.@ 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 .Ed .Sh TODO .obc .It - Translate to Spanish. .El .Sh SEE ALSO .obc .It .Xr ed oh .El .Ss links .obc .It - Lk https://dataswamp.org/~solene/2018-12-04-fun-splitting-line.html Solene - ed split lines .It - Lk https://www.gnu.org/software/diffutils/manual/html_node/Example-ed.html Example ed (Comparing and Merging Files) .It - Lk https://www.gnu.org/software/diffutils/manual/html_node/ed-Scripts.html ed Scripts (Comparing and Merging Files) .It - Lk https://www.unix.com/shell-programming-and-scripting/233897-ed-command-execution-script-file.html unix.com - Ed command execution in script file .El .Sh HISTORY .obc _______ .It 2026-06-02 Ta : Created. .El .Sh AUTHORS .An -nosplit .Xr ohazot oh | .Xr about oh | .Lk https://ohazot.com ohazot.com .Aq Mt admin@ohazot.com