tr(1) CLIX tr(1)
NAME
tr - Translates characters
SYNOPSIS
tr [-cds] [string1 [string2]]
FLAGS
-c Complements the set of characters in string1 with respect to the
universe of characters whose ASCII codes are 001 through 377 octal.
-d Deletes all input characters in string1.
-s Squeezes all strings of repeated output characters that are in
string2 to single characters.
DESCRIPTION
The tr command copies stdin to stdout with substitution or deletion of
selected characters. Input characters found in string1 are mapped into
the corresponding characters of string2. Any combination of the -c, -d,
or -s flags can be used.
The following abbreviation conventions may be used to introduce ranges of
characters or repeated characters into the strings:
[a-z] Stands for the string of characters whose ASCII codes run from
character a to character z, inclusive.
[a*n] Stands for n repetitions of a. If the first digit of n is 0, n is
considered octal; otherwise, n is taken to be decimal. A zero or
missing n is taken to be huge; this facility is useful for padding
string2.
The escape character (\) can be used as in the shell to remove special
meaning from any character in a string. In addition, \ followed by 1, 2,
or 3 octal digits stands for the character whose ASCII code is given by
those digits.
EXAMPLE
1. To create a list of all the words in file1, one per line, in file2,
where a word is taken to be a maximal string of alphabetics:
tr -pcs "[A-Z][a-z]" "[\012*]" <file1 >file2
The strings are quoted to protect the special characters from
interpretation by the shell; 012 is the ASCII code for newline.
2/94 - Intergraph Corporation 1
tr(1) CLIX tr(1)
NOTES
The tr command will not handle the ASCII NUL in string1 or string2; it
deletes any NUL characters from the input.
DIAGNOSTICS
Bad string The tr command is not able to translate a character string.
EXIT VALUES
The tr command exits with a value of 1 if a problem is encountered.
RELATED INFORMATION
Commands: ed(1), sh(1)
2 Intergraph Corporation - 2/94