0
Thanks

A few words of thanks would be greatly appreciated.

Set the 1st letter of each word to Uppercase

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
0
Thanks

A few words of thanks would be greatly appreciated.

Ask a question
Jean-François Pillou

CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jeff Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.

Learn more about the CCM team

Published by . Latest update on by Virginia Parsons.

This document, titled "Set the 1st letter of each word to Uppercase," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (https://ccm.net/).

0 Comments