18.207.255.49 |    

Navigation

Google Advertisement

Mit der Funktion ucwords() wird das erste Zeichen bei jedem Wort in einer Zeichenkette (Text, String) in einen Großbuchstaben (Großschreibung) umgewandelt.

ucwords
  1. # **************************************************************
  2. # ucwords -- Converts first letter of each word within a string
  3. # into an uppercase all other to lowercase.
  4. #
  5. #     string ucwords( string string )
  6.  
  7. function ucwords() {
  8.  
  9. local string="$*"
  10.  
  11. for word in $string; do
  12.     # Get the first character with cut and convert them into uppercase.
  13.     local first="$( echo $word | cut -c1 | tr '[:lower:]' '[:upper:]' )"
  14.  
  15.     # Convert the rest of the word into lowercase and append them to the first character.
  16.     word="$first$( echo $word | cut -c2-${#word} | tr '[:upper:]' '[:lower:]' )"
  17.  
  18.     # Put together the sentence.
  19.     local phrase="$phrase $word"
  20. done
  21.  
  22. echo "$phrase"
  23.  
  24. }
Parsed in 0.005 seconds at 128.21 KB/s

Search
 
Full text search by name and content of a snippet.

User online
There are 3 users online.

Tags Cloud

Latest snippets
last day of last month
(Bash::Snippets)
crypt_apr1_md5
(PHP::Function)
crypt_apr1_md5
(Perl::Function)
transparent
(CSS)
rfc2822Toiso8601
(PHP::Function)
STDERR
(Bash::Function)
radius
(CSS)
shadow
(CSS)
rotate
(CSS)
create_function
(JavaScript::Snippets)