Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to escape period in ed

Tags:

bash

ed

I'm studying the ed text editor.

To exit from input mode, a user should enter a line a single period (.).

Let's say I want to enter the period as text.

I thought of a workaround: first, I insert something like ... Then, I replace .. with ..

But my approach is little unwieldy. Is there a better way to do this?

like image 474
Daniil Iaitskov Avatar asked Oct 26 '13 15:10

Daniil Iaitskov


People also ask

How do I escape bash?

A non-quoted backslash ' \ ' is the Bash escape character. It preserves the literal value of the next character that follows, with the exception of newline .

How do you escape the space characters?

Three Ways to Escape Spaces on WindowsBy enclosing the path (or parts of it) in double quotation marks ( ” ). By adding a caret character ( ^ ) before each space. (This only works in Command Prompt/CMD, and it doesn't seem to work with every command.) By adding a grave accent character ( ` ) before each space.


2 Answers

Reading through the C source for GNU ed(1), there is no escape character. On the occasions that I've wanted to do this, I tend to add a blank line and then use a quick substitution:

a↵
↵
.↵
s/^/.↵

or you can add a character then delete it (which, if you're playing ed(1) golf), is one character more than above)

a↵
x↵
.↵
s/./.↵
like image 147
Gumnos Avatar answered Sep 29 '22 09:09

Gumnos


I didn't found magic escape sequence.

It seems it doesn't exist.

But this link offers 2 solutions. First I described in my question. Second one is closer to a solution with escape.

r ! echo .
like image 28
Daniil Iaitskov Avatar answered Sep 29 '22 08:09

Daniil Iaitskov