TR(1) — Unix Programmer’s Manual
NAME
tr − translate characters
SYNOPSIS
tr [ options ] [ string1 [ string2 ] ]
DESCRIPTION
Tr copies the standard input to the standard output with substitution or deletion of selected characters. Input characters found in string1 are mapped into the corresponding characters of string2. When string2 is short, it is padded to the length of string1 by duplicating its last character.
OPTIONS
Any combination of the options −cds may be used:
−c Complements the set of characters in string1 with respect to the universe of characters which have ASCII codes 01 through 0377 octal.
−d Deletes from input all characters in string1.
−s Squeezes repeated output characters that are in string2 to single characters.
In either string, the notation a−b means a range of characters from a to b in increasing ASCII order. The character \ followed by one, two, or three octal digits stands for the character whose ASCII code is given by those digits. A backslash ( \ ) followed by any other character stands for that character.
EXAMPLE
The following example creates a list of all the words in file1, one per line in file2. A word is taken to be a maximal string of alphabetics. The second string is enclosed in quotes in order to protect \ from the shell. 012 is the ASCII code for newline.
tr −cs A−Za−z ´\012´ <file1 >file2
SEE ALSO
BUGS
Cannot handle ASCII NUL in string1 or string2; always deletes NUL from input.
INTEGRATED SOLUTIONS 4.2 BSD — 1 August 1985