💾 Archived View for perso.pw › blog › articles › fun-trailing-space-ed.gmi captured on 2023-11-04 at 12:05:52. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-05-24)
-=-=-=-=-=-=-
.Dd November 29, 2018
.Dt "Show trailing spaces using ed"
This second fun-tip article will explain how to display trailing
spaces in a text file, using the
.Lk https://man.openbsd.org/ed ed(1)
editor.
ed has a special command for showing a dollar character at the end of
each line, which mean that if the line has some spaces, the dollar
character will spaced from the last visible line character.
.Bd -literal -offset indent
$ echo ",pl" | ed some-file.txt
453
.Dd November 29, 2018$
.Dt "Show trailing spaces using ed"$
This second fun-tip article will explain how to display trailing$
spaces in a text file, using the$
.Lk https://man.openbsd.org/ed ed(1)$
editor.$
ed has a special command for showing a dollar character at the end of$
each line, which mean that if the line has some spaces, the dollar$
character will spaced from the last visible line character.$
$
\&.Bd \-literal \-offset indent$
\$ echo ",pl" | ed some-file.txt$
.Ed
This is the output of the article file while I am writing it. As you
can notice, there is no trailing space here.
The first number shown in the ed output is the file size, because ed
starts at the end of the file and then, wait for commands.
If I use that very same command on a small text files with trailing
spaces, the following result is expected:
.Bd -literal -offset indent
49
this is full $
of trailing $
spaces ! $
.Ed
It is also possible to display line numbers using the "n" command
instead of the "p" command.
This would produce this result for my current article file:
.Bd -literal -offset indent
1559
1 .Dd November 29, 2018$
2 .Dt "Show trailing spaces using ed"$
3 This second fun-tip article will explain how to display trailing$
4 spaces in a text file, using the$
5 .Lk https://man.openbsd.org/ed ed(1)$
6 editor.$
7 ed has a special command for showing a dollar character at the end\
of$
8 each line, which mean that if the line has some spaces, the dollar$
9 character will spaced from the last visible line character.$
10 $
11 .Bd -literal -offset indent$
12 \$ echo ",pl" | ed some-file.txt$
13 453$
14 .Dd November 29, 2018\$
15 .Dt "Show trailing spaces using ed"\$
16 This second fun-tip article will explain how to display trailing\
\$
17 spaces in a text file, using the\$
18 .Lk https://man.openbsd.org/ed ed(1)\$
19 editor.\$
20 ed has a special command for showing a '\\\