tags:

views:

299

answers:

3

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
+4  A: 

This line should do it:

sed -e "s/\b\(.\)/\u\1/g"
tangens
+1  A: 
# awk '{for(i=1;i<=NF;i++){ $i=toupper(substr($i,1,1)) substr($i,2) }}1' file
Trouble Me
Gold Rush Brides
ghostdog74
+2  A: 

Use the following sed command for capitalizing the first letter of the each word.

echo -e "Trouble me \nGold rush brides" | sed -r 's/\<./\U&/g'

output

Trouble Me
Gold Rush Brides
rekha_sri