2
I've noticed that fmt uses two space characters when joining sentences across lines.
Command:
$ fmt << EOF
Hello world.
This is a nice place. And a nice website too. I come here
to ask important questions.
Like this one.
EOF
Output:
Hello world. This is a nice place. And a nice website too. I come here to ask important questions. Like this one.
Is there a way to turn this behaviour off and use a single space instead?
I know that there's a long debate whether one should use 1 or 2 spaces after the period. But this is not relevant in my case. I want to only partially reformat existing text files, typeset using 1 space after the period.
I have done some tests, and it appears that the double space occurs only when a period is followed by a new line, although any multiple spaces mid-sentence are maintained. You can reverse this effect by piping the output through
sed 's/\. /. /g'
. With your here-document, you'll need to start with{ fmt << EOF
and add} | sed 's/\. /. /g'
on the next line. To remove all multiple spaces, usesed 's/ */ /g'
instead (replace space-space asterisk by space, if the format isn't clear). – AFH – 2018-05-08T17:41:31.400