1TR(1) General Commands Manual TR(1)
2
3
4
6 tr - translate characters
7
9 tr [ -cds ] [ string1 [ string2 ] ]
10
12 Tr copies the standard input to the standard output with substitution
13 or deletion of selected characters. Input characters found in string1
14 are mapped into the corresponding characters of string2. When string2
15 is short it is padded to the length of string1 by duplicating its last
16 character. Any combination of the options -cds may be used: -c comple‐
17 ments the set of characters in string1 with respect to the universe of
18 characters whose ASCII codes are 01 through 0377 octal; -d deletes all
19 input characters in string1; -s squeezes all strings of repeated output
20 characters that are in string2 to single characters.
21
22 In either string the notation a-b means a range of characters from a to
23 b in increasing ASCII order. The character `\' followed by 1, 2 or 3
24 octal digits stands for the character whose ASCII code is given by
25 those digits. A `\' followed by any other character stands for that
26 character.
27
28 The following example creates a list of all the words in `file1' one
29 per line in `file2', where a word is taken to be a maximal string of
30 alphabetics. The second string is quoted to protect `\' from the
31 Shell. 012 is the ASCII code for newline.
32
33 tr -cs A-Za-z ´\012´ <file1 >file2
34
36 ed(1), ascii(7), expand(1)
37
39 Won't handle ASCII NUL in string1 or string2; always deletes NUL from
40 input.
41
42
43
447th Edition April 29, 1985 TR(1)