Commit | Line | Data |
---|---|---|
d8649de5 C |
1 | .TH TR 1 "18 January 1983" |
2 | .SH NAME | |
3 | tr \- translate characters | |
4 | .SH SYNOPSIS | |
5 | .B tr | |
6 | [ | |
7 | .B \-cds | |
8 | ] [ string1 [ string2 ] ] | |
9 | .SH DESCRIPTION | |
10 | .I Tr | |
11 | copies the standard input to the standard output with | |
12 | substitution or deletion of selected characters. | |
13 | Input characters found in | |
14 | .I string1 | |
15 | are mapped into the corresponding characters of | |
16 | .IR string2 . | |
17 | When | |
18 | .I string2 | |
19 | is short it is padded to the length of | |
20 | .I string1 | |
21 | by duplicating its last character. | |
22 | Any combination of the options | |
23 | .B \-cds | |
24 | may be used: | |
25 | .B \-c | |
26 | complements the set of characters in | |
27 | .I string1 | |
28 | with respect to the universe of characters | |
29 | whose ASCII codes are 01 through 0377 octal; | |
30 | .B \-d | |
31 | deletes all input characters in | |
32 | .I string1; | |
33 | .B \-s | |
34 | squeezes all strings of repeated output characters that are | |
35 | in | |
36 | .I string2 | |
37 | to single characters. | |
38 | .PP | |
39 | In either string the notation | |
40 | .IB a \- b | |
41 | means a range of characters from | |
42 | .I a | |
43 | to | |
44 | .I b | |
45 | in increasing ASCII order. | |
46 | The character | |
47 | `\e' followed by 1, 2 or 3 octal digits stands for the | |
48 | character whose ASCII code is given by those digits. | |
49 | A `\e' followed by any other character stands | |
50 | for that character. | |
51 | .PP | |
52 | The following example creates a list of all | |
53 | the words in `file1' one per line in `file2', | |
54 | where a word is taken to be a maximal string of alphabetics. | |
55 | The second string is quoted | |
56 | to protect `\e' from the Shell. | |
57 | 012 is the ASCII code for newline. | |
58 | .IP | |
59 | tr \-cs A\-Za\-z \'\e012\' <file1 >file2 | |
60 | .SH "SEE ALSO" | |
61 | ed(1), ascii(7), expand(1) | |
62 | .SH BUGS | |
63 | Won't handle ASCII NUL in | |
64 | .I string1 | |
65 | or | |
66 | .I string2; | |
67 | always deletes NUL from input. |