Commit | Line | Data |
---|---|---|
22fbd3aa | 1 | .\" Copyright (c) 1991 Regents of the University of California. |
94bed826 KB |
2 | .\" All rights reserved. |
3 | .\" | |
ae122740 KB |
4 | .\" This code is derived from software contributed to Berkeley by |
5 | .\" the Institute of Electrical and Electronics Engineers, Inc. | |
6 | .\" | |
22fbd3aa | 7 | .\" %sccs.include.redist.man% |
94bed826 | 8 | .\" |
ae122740 | 9 | .\" @(#)tr.1 6.5 (Berkeley) %G% |
5fc0f5dd | 10 | .\" |
22fbd3aa CL |
11 | .Dd |
12 | .Dt TR 1 | |
13 | .Os | |
14 | .Sh NAME | |
15 | .Nm tr | |
16 | .Nd translate characters | |
17 | .Sh SYNOPSIS | |
18 | .Nm tr | |
19 | .Op Fl c | |
20 | .Op Fl d | Fl s | |
21 | .Ar string1 string2 | |
22 | .Sh DESCRIPTION | |
23 | The tr utility copies the standard input to the standard | |
24 | output with substitution or deletion of selected characters. | |
25 | The options specified and the | |
26 | .Ar string1 | |
27 | and | |
28 | .Ar string2 | |
29 | operands | |
30 | control translations that occur while copying characters. | |
31 | .Pp | |
32 | The following options are available: | |
33 | .Bl -tag -width Ds | |
34 | .It Fl c | |
35 | Complements the set of characters in string1 with | |
36 | respect to the universe of characters whose | |
37 | .Tn ISO | |
38 | 646 | |
39 | [4] codes are 00 through 0377 octal. | |
40 | .It Fl d | |
41 | Deletes all input characters in | |
42 | .Ar string1 . | |
43 | .It Fl s | |
44 | Squeezes all output strings of one or more | |
45 | instances of a single character in | |
46 | .Ar string2 | |
47 | to a | |
48 | single instance of that character. | |
49 | Input characters found | |
50 | in | |
51 | .Ar string1 | |
52 | are mapped into the corresponding characters | |
53 | of | |
54 | .Ar string2 . | |
55 | When | |
56 | .Ar string2 | |
57 | is shorter than | |
58 | .Ar string1 , string2 | |
59 | is extended to the length of | |
60 | .Ar string1 | |
61 | by duplicating the last character of | |
62 | .Ar string2 . | |
63 | If | |
64 | .Ar string2 | |
65 | is explicitly a string of zero | |
66 | length, | |
67 | .Ar string2 | |
68 | is padded with | |
69 | .Tn NUL | |
70 | characters. | |
71 | .El | |
72 | .Pp | |
73 | The following operands are available: | |
74 | .Bl -tag -width stringx | |
75 | .It Ar string1 | |
76 | .It Ar string2 | |
77 | Translation character strings. | |
78 | .El | |
79 | .Pp | |
80 | .Pp | |
81 | If | |
82 | the | |
83 | .Fl c | |
84 | option is given in conjunction with the | |
85 | .Fl d | |
86 | option, then only those characters found in | |
87 | .Ar string1 | |
88 | is copied to the standard output. | |
89 | .Pp | |
90 | The following conventions can be used in | |
91 | .Ar string1 | |
92 | or | |
93 | .Ar string2 | |
94 | or both to specify characters, character ranges, character | |
95 | classes, or collating elements: | |
96 | .Bl -tag -width [[:equiv:]] | |
97 | .It character | |
98 | Represents that character. | |
99 | .It \eoctal | |
100 | A backslash followed by 1, 2, or 3 octal | |
101 | digits represents a character with that | |
102 | encoded value. | |
103 | If a \eoctal sequence is | |
104 | followed by digits, the backslash and up to | |
105 | three digits are interpreted to prepare a | |
106 | character; subsequent digits are interpreted | |
107 | as individual characters. | |
108 | .It \echaracter | |
109 | A backslash followed by any character except | |
110 | an octal digit represents that character. | |
111 | .It [c-c] | |
112 | Represents the range of ordered elements | |
113 | between the range endpoints, inclusive. | |
114 | .\" ; as | |
115 | .\" defined by the current setting of the | |
116 | .\" setlocale() category | |
117 | .\" .Em LC_COLLATE . | |
118 | .\" The collating | |
119 | .\" elements are ordered in ascending collating | |
120 | .\" sequence, and the first endpoint shall precede | |
121 | .\" the second in the collating sequence. | |
122 | .It [[:class:]] | |
123 | Represents all characters belonging to the | |
124 | defined character class. | |
125 | .\" as defined by the | |
126 | .\" current setting of the setlocale() category | |
127 | .\" .Ev LC_CTYPE . | |
128 | Allowable names for class are: | |
129 | .Bl -column alpha upper lower digit xdigit -offset indent | |
130 | alpha upper lower digit xdigit alnum | |
131 | space punct print graph cntrl | |
132 | .El | |
133 | .Pp | |
134 | The characters placed in ascending order. | |
135 | .\" .Em LC_COLLATE . | |
136 | .\" (Characters not defined in the | |
137 | .\" current collating sequence are ordered | |
138 | .\" according to the collation sequence's rules | |
139 | .\" for ordering of undefined characters.) | |
140 | .It [[=equiv=]] | |
141 | Represents all characters or collating (sorting) | |
142 | elements belonging to the same equivalence class | |
143 | as equiv. | |
144 | .\" | |
145 | .\" | |
146 | .\" .Em LC_COLLATE . | |
147 | If | |
148 | there is a secondary ordering within the | |
149 | equivalence class, the characters are ordered | |
150 | in ascending sequence. | |
151 | Otherwise, they are | |
152 | ordered after their encoded values. | |
153 | .It [[.cs.]] | |
154 | Represents a collating symbol. | |
155 | Multicharacter | |
156 | collating symbols shall be represented as | |
157 | collating symbols to distinguish them from a | |
158 | string of the same characters. | |
159 | .It [x*n] | |
160 | Represents n repeated occurrences of the | |
161 | character or collating symbol x. | |
162 | This | |
163 | expression is only valid when it occurs in | |
164 | .Ar string2 . | |
165 | If n is omitted or is zero, it is | |
166 | be interpreted as large enough to extend the | |
167 | .Ar string2 Ns -based | |
168 | sequence to the length of the | |
169 | .Ar string1 Ns -based | |
170 | sequence. | |
171 | If n has a leading | |
172 | zero, it shall be interpreted as an octal | |
173 | value. | |
174 | Otherwise, it shall be interpreted as | |
175 | a decimal value. | |
176 | .El | |
177 | .Pp | |
178 | Characters belonging to an equivalence class occupy the same | |
179 | position in the sequence, ordered after secondary ordering. | |
180 | .Pp | |
181 | The | |
182 | .Nm tr | |
183 | utility exits with one of the following values: | |
184 | .Bl -tag -width Ds | |
185 | .It 0 | |
186 | All input was processed successfully. | |
187 | .It 1 | |
188 | An error occurred. | |
189 | .El | |
190 | .Sh STANDARDS | |
191 | The | |
192 | .Nm tr | |
193 | utility is expected to be | |
194 | .Tn POSIX | |
195 | 1003.2 compatible. |