Technical article 105318

How can I use tr(C) to translate between upper and lower case?

OpenServer 5.0.0OpenServer 5.0.2

Written · Last revised

Problem

In earlier releases of SCO UNIX Operating System you could use the command:

cat file1 | tr '[A-Z]' '[a-z]' > file2

to translate the characters in file1 from upper case to lower case and write the output to file2. This syntax does not work anymore.

How can I translate between cases in SCO OpenServer Release 5?

Cause

The tr(C) command has been changed to comply with:

ISO/IEC DIS 9945-2:1992/POSIX 1003.2 X/Open CAE Specification, Commands and Utilities, Issue 4, 1992

a-z and A-Z are no longer reliable as SCO OpenServer now supports character sets where the characters a and b may not be adjacent.

See locale(M) for further details on how to select a character
set using the LANG environment variable.

Solution

To translate from upper case to lower case, use the following command:

cat file1 | tr "[:upper:]" "[:lower:]" > file2

To translate file1 from lower case to upper case use:

cat file1 | tr "[:lower:]" "[:upper:]" > file2
NOTE:     tr(C) can still use '[A-Z]' and '[a-z]' if your locale is set
          to the POSIX locale. This can be done as follows for the
          sh(C) and ksh(C):
LANG=C_C.C; export LANG
For the csh(S):
setenv LANG C_C.C

See also

Other articles in this database related to the default language,
"I changed the system locale and now the calendar server does not
 start",  and
"sort(C) tr(C) and ls(C) and other utilities are sorting numbers in
 the wrong order"

From the Xinuos technical article database, record 105318. Reproduced with permission. The original is at www.sco.com/ta/105318, which is reachable but blocked from search engines. Xinuos marks this article against a retired product line. That refers to the product’s lifecycle, not to whether the advice still works — plenty of it still applies to running systems.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.