⚠️ Not tested!
# Converts to upper-case:
# first word-letter at start or following a period
$ sed -e 's/^.|\.\w+/\u&/g' input.txt > output.txt
This uses common regular expression matcher:
^
start of line, followed by any single character .
(i.e. the initial letter at start)
|
as boolean OR
\.
for the period, followed by \w+
for one or many word-characters (letters)
but also some specials like:
- back-reference
&
(full match pattern), where following is applied to:
- transformation from GNU extensions
\u
(uppercase the next character of match), that may not work on MacOS.
Use sed's GNU extensions on MacOS
On MacOS (BSD sed) you can use gsed
which must be installed, e.g. using homebrew:
brew install gnu-sed
Inspired by: https://stackoverflow.com/a/4581564
Alternatively you may achieve same (regex-uppercase transformation) by using Perl: https://unix.stackexchange.com/a/615804