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
Hi.
What have you tried? ... cheers, drl
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
$
Hi.
Here's one way:
#!/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:
% ./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
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