Set the 1st letter of each word to Uppercase

December 2016

You may be in a situation where you need to set letters in uppercase mode whilst typing: you could be writing a letter in Microsoft Word for example and require capital letters throughout your document. Similarly with programming the use of uppercase is often required. There are two methods by which uppercase can be set on the first letter of each word you type. It differs from person to person which one they decide to use, but the sed command along with echo is compulsory in both cases.
Below are two ways to proceed:

Method 1
sed-r 's /(^.|.) / \ U & / g'

Method 2
sed 's / ^. \ | [a-z] / \ U & / g'

Method 3
sed-r 's / \ <. / \ U & / g'

Examples:
$ Echo-e "good day to you | Sed-r 's /(^.|.) / \ U & / g'
Good Day To You.

$ Echo-e "hello life \ net hello to you" | sed-r 's /(^.|.) / \ U & / g'
or
$ Echo-e "hello life \ net hello to you" | sed-r 's / (\ b) / \ U & / g'
Hello Life
And Hello To You

$ Echo-e "hello life." | Sed 's / ^. \ | [A-z] / \ U & / g'
Hello Life.

$ Echo-e "hello life \ net hello to you" | sed 's / ^. \ | [Az] / \ U & / g'
Hi Life
And Hello To You

Related :

This document entitled « Set the 1st letter of each word to Uppercase » from CCM (ccm.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.