Converting text to all upper case or all lower case is a fairly common task.
One way to convert text to upper case would be to use the
tr utility to replace the letters a through z with the letters A through Z. For example,
$ echo Now is the time | tr '[a-z]' '[A-Z]' NOW IS THE TIME
You could convert to lower case by reversing the arguments to
The approach above works if your text consists of only unadorned Roman letters. But it wouldn’t work, for example, if you gave it a jalapeño or π:
$ echo jalapeño π | tr '[a-z]' '[A-Z]' JALAPEñO π
Using the character classes
[:upper:] won’t help either.
Tussling with Unicode
One alternative would be to use the
uc command from the Unicode::Tussle package  I mentioned a few days ago. There’s also a
lc counterpart, and a
tc for title case. These utilities handle far more than Roman letters.
$ echo jalapeño π | uc JALAPEÑO Π
Unicode capitalization rules are a black hole, but we’ll just look at one example and turn around quickly before we cross the event horizon.
Suppose you want to send all the letters in the Greek word σόφος to upper case.
$ echo σόφος | uc ΣΌΦΟΣ
Greek has two lower case forms of sigma: ς at the end of a word and σ everywhere else. But there’s only one upper case sigma, so both get mapped to Σ. This means that if we convert the text to upper case and then to lower case, we won’t end up exactly where we started.
$ echo σόφος | uc | lc σόφοσ
Note that the
lc program chose σ as the lower case of Σ and didn’t take into account that it was at the end of a word.
 “Tussle” is an acronym for Tom [Christiansen]’s Unicode Scripts So Life is Easier.