COHERENT manpages
This page displays the COHERENT manpage for tr [Translate characters].
List of available manpages
Index
tr -- Command Translate characters tr [-cds] string1 [string2] tr reads characters from the standard input, possibly translates each to another value or deletes it, and writes to standard output. Each specified string may contain literal characters of the form a or \b (where b is non-numeric), octal representations of the form \ooo (where o is an octal digit), and character ranges of the form X-Y. tr rewrites each string with the appropriate conversions and range expansions. If an input character is in string1, tr outputs the corresponding character of string2. If string2 is shorter than string1, the result is the last character in string2. The following flags control how tr translates characters: -c Replace string1 by the set of characters not in string1. -d Delete characters in string1 rather than translating them. -s The ``squeeze'' option: map a sequence of the same character from string1 to one output character. Example The following example prints all sequences of four or more spaces or printing characters from infile: tr -cs ' -~' '\12' <infile | grep .... Here string1 is the range from <space> to `~', which includes all printing characters. Because this example uses the flags -cs, tr maps sequences of nonprinting characters to newline (octal 12). See Also ASCII, commands, ctype.h, sed Notes Beginning with COHERENT 4.2, the command echo "This is a test." | tr returns This is a test. This behavior does not conform with POSIX Standard, but is required by a number of third-party packages.