Re: first letter of the word in CAPS
On 21 Aug 2006 23:33:58 -0700, aarcee wrote:
> Hello all ,
>
> I need to display a word with the first character in CAPS .
>
> that is , split then the display should be Split
[...]
With zsh:
word=foo
Word=${(C)word}
(will captitalise every word in $word (turns " foo bar" into
" Foo Bar").
With other shells:
Word=$(
awk '
BEGIN {
print toupper(substr(ARGV[1], 1, 1)) \
tolower(substr(ARGV[1], 2))
exit
}' "$word"
)
Captitalises only the first character in $word.
--
Stephane
|