Questions tagged [ed]
For questions about the editor ed, a scriptable line-oriented text editor, originally written by Ken Thompson for the Multics and Unix operating systems. Use this tag for questions about ed itself or questions about issues arising from using the ed editor.
90 questions
1 vote
1 answer
122 views
Why can't I run an interactive command in awk in a pipeline?
Consider the following commands: $ awk 'BEGIN { system("ed") }' q $ echo hello | awk 'BEGIN { system("ed") }' ? $ In the first case, I was able run ed and then stay in the editor ...
1 vote
1 answer
103 views
How do you put fzf CTRL-R into rlwrap ed?
I sourced the /usr/share/doc/fzf/examples/key-bindings.bash file so fzf works in Bash; but how do you get that to work with the rlwrap ed approach?
1 vote
1 answer
57 views
With ed, reach to the next occurrence
Consider a file with an AsciiDoc ordered list like this: . one + ---- echo hello # arbitrary lines... echo world ---- . two . three How do you move the code block to some arbitrary place in the list (...
1 vote
1 answer
93 views
How to use tabs with `rlwrap ed`?
On my macOS and Linux systems, I run ed with alias ed='rlwrap ed'. On macOS with rlwrap 0.46.1 (2022) I can freely create files with tabs like: $ ed a foo<TAB>bar but on my Linux systems with ...
5 votes
3 answers
194 views
With ed, how do you fold and unfold lines?
Given the following file: foo bar baz this and that then I can easily "unfold" those lines with global substitution with ed(1): g/ /s//\ /g which gives: foo bar baz this and that But what'...
1 vote
1 answer
281 views
A use case for the 'r' suffix to the substitution command in GNU Ed?
I am running GNU Ed on Fedora Linux. The GNU Ed manual cryptically refers to an 'r' suffix for the s command, to be distinguished from the 'r' command. All it says about it is the following: The ...
3 votes
1 answer
175 views
Showing whitespace in Ed
In Ed I can test for whitespace with this regex: g/ *$/p. I don't suppose there is a way of showing whitespace, perhaps by passing the contents of the buffer to another shell command?
1 vote
2 answers
123 views
Can the ed editor be configured to automatically create backup files?
Is there a way to have ed create backups of the file currently loaded into the buffer. On occasion I have inadvertently overwritten my file and found it's not recoverable. I.e. making a backup file ...
0 votes
3 answers
123 views
Edit inside an HTML tag with ed(1)
Consider my humble hello.html file, edited with mighty ed: $ ed hello.html 28 ,p <title>Hello world!</title> What's your general approach to edit inside that title HTML tag (bonus if you ...
6 votes
1 answer
352 views
Why can't I print this regex range with ed(1)?
I'm totally mystified why I can't print this range with ed when there are two ranges—see file2.tf file—; but I can print when there is only one range—see file1.tf file—and I can print with the gsed (...
1 vote
4 answers
139 views
Remove last line of file by any user, owned by root
I have a file with permissions 666 so users can edit it with a different script. This works. I need to script to remove the last line of the file, however this is not working as using something like ...
1 vote
2 answers
234 views
POSIX way to add content around a line in a file
I'm looking for a way to edit files with a script that will provide an alternate definition for a variable in C and this redefinition is controlled by a compiler D-flag using a POSIX application that ...
2 votes
1 answer
220 views
How to increase the size of the .ed_history file
I am running GNU ed 1.18 on Fedora Linux 36. I run ed with rlwrap also installed which gives me access to my command history. My .ed_history file appears to have a size limit of 300 lines. I would ...
0 votes
1 answer
944 views
Inserting the line to be changed in ed
In ed there is the useful c command which allows one to make changes to a specific line. (Using rlwrap as well allows for easier changes, once a line has already been changed, because one can use the ...
3 votes
3 answers
1k views
Replacing strange characters in a sed command
I want to create a sed command that will remove all of these strange characters from a given document: sed -n 's/\|®MD-IT¯\|®MD\+BO¯\|®MDNM¯®LL\.8LI,0LI¯\|®LL0LI,0LI¯\|®MD\+IT¯\|®LL.8LI,0LI¯®MDIT¯\|®...