# Simple ed questions - insert line with dot

**URL:** <https://community.unix.com/t/simple-ed-questions-insert-line-with-dot/177295>\
**Category:** UNIX for Dummies Questions & Answers\
**Created:** [November 1, 2007, 4:30pm UTC](https://community.unix.com/t/simple-ed-questions-insert-line-with-dot/177295 "2007-11-01T16:30:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![peterl](https://community.unix.com/user_avatar/community.unix.com/peterl/32/3857_2.png) [@peterl](https://community.unix.com/u/peterl)\
**Post date:** [November 1, 2007, 4:30pm UTC](https://community.unix.com/t/simple-ed-questions-insert-line-with-dot/177295/1 "2007-11-01T16:30:53Z")

</div>

Hi  
I've got a trivial question on using ed (yes, I know, other editors are better!)  
How do I insert a line that is just a single dot? (That is, how do I insert a line that starts with a dot and then new line)  
Thanks  
Peter

---

<div class="post-metadata">

**Author:** ![drl](https://community.unix.com/user_avatar/community.unix.com/drl/32/542_2.png) [@drl](https://community.unix.com/u/drl)\
**Post date:** [November 2, 2007, 7:34am UTC](https://community.unix.com/t/simple-ed-questions-insert-line-with-dot/177295/2 "2007-11-02T07:34:11Z")

</div>

Hi.

What have you tried? ... cheers, drl

---

<div class="post-metadata">

**Author:** ![peterl](https://community.unix.com/user_avatar/community.unix.com/peterl/32/3857_2.png) [@peterl](https://community.unix.com/u/peterl)\
**Post date:** [November 4, 2007, 9:43pm UTC](https://community.unix.com/t/simple-ed-questions-insert-line-with-dot/177295/3 "2007-11-04T21:43:29Z")

</div>

Here's my entries:

$ ed  
a  
. enter a line of just a dot  
But it doesn't enter a line with a dot, it leaves  
insert mode  
w file.txt  
0 There's nothing in the buffer  
q  
$

---

<div class="post-metadata">

**Author:** ![drl](https://community.unix.com/user_avatar/community.unix.com/drl/32/542_2.png) [@drl](https://community.unix.com/u/drl)\
**Post date:** [November 4, 2007, 10:21pm UTC](https://community.unix.com/t/simple-ed-questions-insert-line-with-dot/177295/4 "2007-11-04T22:21:32Z")

</div>

Hi.

Here's one way:

```nohighlight
#!/usr/bin/env sh

# @(#) s1 Demonstrate one way to get a ".", dot into a file with ed.

set -o nounset
echo

debug=":"
debug="echo"

## Use local command version for the commands in this demonstration.

echo "(Versions displayed with local utility \"version\")"
version >/dev/null 2>&1 && version bash ed

echo

# Create a file.
cat >data1 <<'EOF'
Hi.
Goodbye.
EOF

echo " Input file:"
cat data1

echo
echo " Conversation with ed:"
ed data1 <<'EOF'
1
a
.x
.
s/x//
w
q
EOF

echo
echo " Results from ed"
cat data1

exit 0

```

Producing:

```nohighlight
% ./s1

(Versions displayed with local utility "version")
GNU bash 2.05b.0
GNU ed version 0.2

 Input file:
Hi.
Goodbye.

 Conversation with ed:
13
Hi.
15

 Results from ed
Hi.
.
Goodbye.

```

cheers, drl

---

<div class="post-metadata">

**Author:** ![peterl](https://community.unix.com/user_avatar/community.unix.com/peterl/32/3857_2.png) [@peterl](https://community.unix.com/u/peterl)\
**Post date:** [November 4, 2007, 10:53pm UTC](https://community.unix.com/t/simple-ed-questions-insert-line-with-dot/177295/5 "2007-11-04T22:53:25Z")

</div>

Thanks. So I see one way to do it would be to enter a line of:  
.x  
and then substitute the x for nothing, leaving just the dot.  
Thanks for your help  
Peter
