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