Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uppercasing First Letter of Words Using SED

How do you replace the first letter of a word into Capital letter, e.g.

Trouble me Gold rush brides 

into

Trouble Me Gold Rush Brides 
like image 925
neversaint Avatar asked Oct 08 '09 15:10

neversaint


People also ask

How do you capitalize the first letter in Linux?

Use ^ to convert the first letter to uppercase and ^^ to convert all characters to uppercase. Use , to convert the first letter to lowercase and ,, to convert all characters to lowercase. Use ~ to toggles the case for the first character and ~~ to toggle cases for all characters.

How do you make the first letter capital in Unix?

@CMCDragonkai: To lowercase the first letter, use "${foo,}" . To lowercase all the letters, use "${foo,,}" . To uppercase all the letters, use "${foo^^}" .

How do you change from lowercase to uppercase in Linux?

To define uppercase, you can use [:upper:] or [A-Z] and to define lowercase you can define [:lower:] or [a-z]. The `tr` command can be used in the following way to convert any string from uppercase to lowercase. You can use `tr` command in the following way also to convert any string from lowercase to uppercase.


1 Answers

This line should do it:

sed -e "s/\b\(.\)/\u\1/g" 
like image 169
tangens Avatar answered Sep 28 '22 09:09

tangens