Afficher un message
Vieux 22/08/2006, 09h39   #4
Stephane Chazelas
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 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
  Réponse avec citation
 
Page generated in 0,04227 seconds with 9 queries