TR(1) — UNIX Programmer’s Manual
NAME
tr − translate characters
SYNOPSIS
tr [ −cds ] [ 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. Any combination of the options −cds may be used: −c complements the set of characters in string1 with respect to the universe of characters with ASCII codes which are 01 through 0377 octal; −d deletes all input characters in string1; −s squeezes all strings of repeated output characters that are in string2 to single characters.
In either string, the notation a−b indicates a range of characters from a to b in increasing ASCII order. The character ‘\’, followed by 1, 2 or 3 octal digits represents the ASCII character code given by those digits. A ‘\’ followed by any other character stands for that character.
The following example creates a list of all words in ‘file1’, one per line in ‘file2’, where a word is interperted as a maximal string of alphabetics. The second string is quoted to protect ‘\’ from the Shell. 012 is the ASCII code for newline.
tr −cs A−Za−z ´\012´ <file1 >file2
SEE ALSO
BUGS
Won’t handle ASCII NUL in string1 or string2; always deletes NUL from input.
November 03, 1983 — %W%%Q%%Y%