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