Vonnegut Imperative: Replace semicolons with periods * correct *
This question is a bit shy, but I'm also very curious about the correct and clean way to do this.
Background: Kurt Vonnegut said that semicolons are useless punctuation points. All they do is show that you went to college.
Anyway, I know that if I have a text file (like "test.txt") with a bunch of useless semicolons separating "closely related" sentences, I can find and replace:
sed 's/;/./g' <test.txt >better.txt
Which will replace all those annoying half-columns with periods. However, now I have a problem that all new periods are followed by words without the first letter with a capital letter (since one word is not used after the comma).
Is there a way (hopefully via sed) to automatically replace all semicolons in a text file with periods AND also automatically capitalize the first letter of words after newly inserted periods?
Thanks hft
source to share
Short answer. Yes of course.
Here's an example using GNU sed
:
$ echo "hello;world;i;am;here" | sed 's/;\(.\)/.\U\1/g'
hello.World.I.Am.Here
For the standard case of semi-column prose followed by the use of space:
$ echo " Hello; world; blah" | sed 's/; *\(.\)/. \U\1/g'
Hello. World. Blah
source to share