MPE/iX Shell and Utilities Reference Manual, Vol 2

tr(1) MPE/iX Shell and Utilities tr(1)
String Elements
You can use the following conventions to represent elements of string1 and string2.
character
Any character not described by the conventions that follow represents itself.
\ooo An octal representation of a character with a specific coded value. It can consist of
one, two, or three octal digits.
\character
The \ (backslash) character is used as an escape to remove the special meaning of
characters. It also introduces escape sequences for non-printing characters, in the
manner of C character constants: \b, \f, \n, \r, \t, and \v.
c1c2 This represents all characters between characters c1 and c2 (in the current locale’s
collating sequence) including the end values. For example, a–z represents all the
lowercase letters in the
POSIX locale while A–Z represents all that locale’s uppercase
letters. One way to convert lowercase and uppercase is with the following filter:
tr ’a-z’ ’A-Z’
This is not, however, the recommended method, use the [:class:] construct in-
stead.
c*n This represents n repeated occurrences of character c. (If n has a leading zero, tr as-
sumes it is octal; otherwise, it is assumed to be decimal.) You can omit the number
for the last character in a subset. This representation is only valid in string2.
[:class:]
This represents all characters that belong to the character class class in the locale in-
dicated by
LC_CTYPE
. When the class [:upper] or [:lower:] appears in
string1 and the opposite class, [:lower:] or [:upper:] appears in string2, tr
uses the
LC_CTYPE
tolower or toupper mappings in the same relative posi-
tions.
[=c=] This represents all characters which belong to the same equivalence class as the char-
acter c in the locale indicated by
LC_COLLATE
. Only internationalized versions of
the code support this format.
EXAMPLES
tr -cs "[:alpha:]" "\n*" <file1 >file2
creates a list of all words (strings of letters) found in file1 and puts it in file2.
1-612 Commands and Utilities