Reputation: 257
Suppose I have opened a text file in ed, and the current line looks like this:
This is sentence one. Here starts another one.
Now I want to put a newline after one.
, such that the new sentence starting with Here starts
occupies the next line.
How do I do this in ed?
Upvotes: 6
Views: 1993
Reputation: 91
You can do
t.
s/text_before/
-s/text_after/
Explanation:
t.
copies the line, in order to get 2 consecutive identical lines, both containing the original text.NOTE: The '-' prefix means, do it for the previous (of the current addressed) line.
Upvotes: 2
Reputation: 11
Use the following command at ed:
s/\. /\.\
/
Be aware that there are two lines.
Using 1,$p
you will see the expected result.
Upvotes: 1
Reputation: 17323
You use the s
command to make substitutions. The format is:
s/pattern/replacement/
To include a newline in the replacement, escape it with a backslash, then press the return key:
s/one. /one.\
/
Where you literally press return, rather than include a \r
or \n
.
Upvotes: 8