1 .\" You may copy, distribute and modify under the terms of the LDP General
2 .\" Public License as specified in the LICENSE file that comes with the
3 .\" gnumaniak distribution
5 .\" The author kindly requests that no comments regarding the "better"
6 .\" suitability or up-to-date notices of any info documentation alternative
7 .\" is added without contacting him first.
9 .\" (C) 2002 Ragnar Hojland Espinosa <ragnar@ragnar-hojland.com>
12 .\" man pages are NOT obsolete!
13 .\" <ragnar@ragnar-hojland.com>
15 .\" Japanese Version Copyright (c) 2000 NAKANO Takeo all rights reserved.
16 .\" Translated Sun 12 Mar 2000 by NAKANO Takeo <nakano@apm.seikei.ac.jp>
18 .TH TR 1 "7 October 2002" "GNU textutils 2.1"
20 .\"O \fBtr\fR \- translate, squeeze, and/or delete characters
22 tr \- ʸ»ú¤ÎÊÑ´¹¡¦ºï½ü¤ä¡¢Ï¢Â³¤¹¤ëʸ»ú¤Î°µ½Ì¤ò¹Ô¤¦
27 .RB [ \-\-complement ]
29 .RB [ \-\-squeeze\-repeats ]
30 .RB [ \-\-truncate\-set1 ]
32 .\" .IR FILE1 " [" FILE2 ]
35 .BR tr " [" \-\-help "] [" \-\-version ]
39 .\"O copies standard input to standard output, performing one of the
40 .\"O following operations:
42 ¤Ïɸ½àÆþÎϤòɸ½à½ÐÎϤ˥³¥Ô¡¼¤·¡¢¤½¤ÎºÝ¤Ë°Ê²¼¤Î¤¦¤Á¤Î¤¤¤º¤ì¤«¤ò¹Ô¤¦¡£
44 .\"O \fB\(bu\fR translate, and optionally squeeze repeated characters in the result
46 ʸ»ú¤òÊÑ´¹¤·¡¢¥ª¥×¥·¥ç¥ó¤Ç»ØÄꤹ¤ì¤Ð¤µ¤é¤ËϢ³¤¹¤ëʸ»ú¤ò°µ½Ì
49 .\"O \fB\(bu\fR squeeze repeated characters
51 Ϣ³¤¹¤ëʸ»ú¤ò°µ½Ì¤¹¤ë¡£
53 .\"O \fB\(bu\fR delete characters
57 .\"O \fB\(bu\fR delete characters, then squeeze repeated characters from the result
59 ʸ»ú¤òºï½ü¤·¤Æ¤«¤é¡¢Ï¢Â³¤¹¤ëʸ»ú¤ò°µ½Ì¤¹¤ë¡£
61 .\"O The \fISET1\fR and (if given) \fISET2\fR arguments define ordered sets of
62 .\"O characters, referred to below as \fISET1\fR and \fISET2\fR. These sets are
63 .\"O the characters of the input that \fBtr\fR operates on. The \fB\-c\fR option
64 .\"O replaces \fISET1\fR with its complement (all of the characters that are not
66 \fISET1\fP ¤ª¤è¤Ó (Í¿¤¨¤é¤ì¤Æ¤¤¤ì¤Ð) \fISET2\fP °ú¤¿ô¤Ï¡¢
67 ʸ»ú¤Î½ç½øÉÕ¤¥»¥Ã¥È¤òÄêµÁ¤¹¤ë¡£
68 .\"nakano: °ÕÌ£¤Ê¤·(^^;
69 .\" °Ê²¼¤ÎÀâÌÀ¤Ç¤Ï¤³¤ì¤ò \fISET1\fP ¤ª¤è¤Ó \fISET2\fP ¤È¸Æ¤Ö¡£
70 ¤³¤ì¤é¤Îʸ»ú¥»¥Ã¥È¤¬ÆþÎϤ˸ºß¤¹¤ë¤È¡¢
72 ¤Ï¤½¤Îʸ»ú¤ËÂФ·¤ÆÆ°ºî¤ò¹Ô¤¦¡£
73 .\"nakano: °Ê²¼¤Ï¾éĹ¤Êµ¤¤¬...
75 .\" ¥ª¥×¥·¥ç¥ó¤Ï \fISET\fP ¤ò¤½¤ÎÊ佸¹ç
76 .\" (\fISET1\fP ¤Ë´Þ¤Þ¤ì¤Ê¤¤Ê¸»ú¤¹¤Ù¤Æ) ¤ËÃÖ´¹¤¹¤ë¡£
80 .B \-c, \-\-complement
81 .\"O Replace \fISET1\fR with its complement (that is, all the characters that are
82 .\"O not in \fISET1\fR.
83 \fISET1\fR ¤ò¡¢ \fISET1\fR ¼«¿È¤ÎÊ佸¹ç
84 (\fISET1\fR ¤Ë´Þ¤Þ¤ì¤Ê¤¤Ê¸»ú¤¹¤Ù¤Æ) ¤ÇÃÖ¤´¹¤¨¤ë¡£
87 .\"O Delete any input characters that are in \fISET1\fR, do not translate.
88 \fISET1\fP ¤Ë¤¢¤ëÆþÎÏʸ»ú¤òºï½ü¤¹¤ë¡£ÊÑ´¹¤·¤Ê¤¤¡£
90 .B \-s, \-\-squeeze\-repeats
91 .\"O Replace sequence of characters with one; this is done after translating or
92 .\"O deleting. It replaces each input sequence of a repated character that is in
93 .\"O \fISET1\fR with a single occurrence of that character.
94 Ʊ¤¸Ê¸»ú¤Î·«¤êÊÖ¤·¤ò 1 ʸ»ú¤ËÃÖ¤´¹¤¨¤ë¡£
95 ¤³¤ÎÁàºî¤ÏÊÑ´¹¤äºï½ü¤Î¤¢¤È¤Ë¹Ô¤ï¤ì¤ë¡£
96 \fISET1\fP ¤Ë¤¢¤ëʸ»ú¤Î·«¤êÊÖ¤·¤ò¡¢¤½¤Îʸ»ú 1 ʸ»ú¤ËÃÖ¤´¹¤¨¤ë¡£
98 .B \-t, \-\-truncate\-set1
99 .\"O Before doing any translations, first truncate \fISET1\fR to length of
101 ÊÑ´¹¤ò¹Ô¤¦Á°¤Ë¡¢¤Þ¤º \fISET1\fP ¤ò \fISET2\fP ¤ÎŤµ¤ËÀÚ¤êµÍ¤á¤ë¡£
104 .\"O Print a usage message on standard output and exit successfully.
105 ɸ½à½ÐÎϤ˻ÈÍÑÊýË¡¤Î¥á¥Ã¥»¡¼¥¸¤ò½ÐÎϤ·¤ÆÀµ¾ï½ªÎ»¤¹¤ë¡£
108 .\"O Print version information on standard output then exit successfully.
109 ɸ½à½ÐÎϤ˥С¼¥¸¥ç¥ó¾ðÊó¤ò½ÐÎϤ·¤ÆÀµ¾ï½ªÎ»¤¹¤ë¡£
110 .\"O .SH SPECIFYING SETS
112 .\"O The format of the \fISET1\fR and \fISET2\fR arguments resembles the format of
113 .\"O regular expressions; however, they are not regular expressions, only
114 .\"O lists of characters. Most characters simply represent themselves in
115 .\"O these strings, but the strings can contain the shorthands listed below,
116 .\"O for convenience. Some of them can be used only in \fISET1\fR or \fISET2\fR,
118 \fISET1\fP ¤ª¤è¤Ó \fISET2\fP °ú¤¿ô¤Î¥Õ¥©¡¼¥Þ¥Ã¥È¤Ï
119 Àµµ¬É½¸½¤È»÷¤¿¤â¤Î¤Ë¤Ê¤Ã¤Æ¤¤¤ë¡£¤·¤«¤·Àµµ¬É½¸½¤½¤Î¤â¤Î¤Ç¤Ï¤Ê¤¯¡¢
120 ¼Â¤Ïʸ»ú¤ÎʤӤ˲᤮¤Ê¤¤¡£
121 ¤³¤ì¤é¤Îʸ»úÎó¤ÎÃæ¤Ëµ¤µ¤ì¤¿Ê¸»ú¤Ï¡¢¤Û¤È¤ó¤É¤Î¾ì¹ç¤Ï¤½¤Îʸ»ú¼«¿È¤ò»Ø¤¹¡£
122 ʸ»úÎó¤Ë¤ÏÊص¹¾å°Ê²¼¤Î¤è¤¦¤Êû½Ì·Á¤òÍѤ¤¤ë¤³¤È¤â¤Ç¤¤ë¡£
123 ¤¿¤À¤· \fISET1\fP ¤Þ¤¿¤Ï \fISET2\fP ¤Î¤¤¤º¤ì¤«¤Ë¤·¤«
124 ÍѤ¤¤ë¤³¤È¤Î¤Ç¤¤Ê¤¤¤â¤Î¤â¤¢¤ë (¤³¤Î¤è¤¦¤Ê¤â¤Î¤Ë¤ÏÃíµ¤¬¤µ¤ì¤Æ¤¤¤ë)¡£
125 .\"O .SS Backslash Escapes
126 .SS ¥Ð¥Ã¥¯¥¹¥é¥Ã¥·¥å¤òÍѤ¤¤¿¥¨¥¹¥±¡¼¥×
151 .\"O The character with the value given by \fIOOO\fR, which is 1 to 3 octal digits
152 \fIOOO\fP (1¡Á3 ·å¤Î 8 ¿Ê¿ô) ¤Ë¤è¤Ã¤Æ»ØÄꤵ¤ì¤ëʸ»ú
160 .\"O The notation `\fIM\fR\-\fIN\fR' expands to all of the characters from
161 .\"O \fiM\fR through \fIN\fR, in ascending order. \fIM\fR should collate before
162 .\"O \fIN\fR; if it doesn't, an error results. As an example, `0\-9' is the same as
163 .\"O `0123456789'. Although GNU \fBtr\fR does not support the System V
164 .\"O syntax that uses square brackets to enclose ranges, translations
165 .\"O specified in that format will still work as long as the brackets
166 .\"O in \fISTRING1\fR correspond to identical brackets in \fISTRING2\fR.
167 `\fIM\fR\-\fIN\fR' ¤È¤¤¤Ã¤¿É½µ¤Ï¡¢
168 \fIM\fP ¤«¤é \fIN\fP ¤Þ¤Ç¤Î¤¹¤Ù¤Æ¤Îʸ»ú¤ò¾º½ç¤ËŸ³«¤·¤¿Ê¸»úÎó¤Ë¤Ê¤ë¡£
169 \fIM\fP ¤Ï¾È¹ç½ç½øÃæ¤Ç \fIN\fP ¤ÎÁ°¤Ë¤Ê¤±¤ì¤Ð¤Ê¤é¤º¡¢
170 ¤³¤ì¤ËÈ¿¤·¤¿¾ì¹ç¤Ï¥¨¥é¡¼¤È¤Ê¤ë¡£
171 Î㤨¤Ð `0\-9' ¤Ï`0123456789' ¤ò»ØÄꤷ¤¿¤Î¤ÈƱ¤¸¤³¤È¤Ë¤Ê¤ë¡£
174 ¤Ç¤ÏÈϰϤò»ØÄꤹ¤ëºÝ¤Ë³Ñ³ç¸Ì `[]' ¤òÍѤ¤¤ë¤¬¡¢
177 ¤Ç¤Ï¤³¤Î·Á¼°¤Ï¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Ê¤¤¡£
178 ¤¿¤À¤·¤³¤Î·Á¼°¤Ë¤ª¤±¤ëÊÑ´¹»ØÄê¤Ï
179 \fISET1\fP ¤È \fISET2\fP ¤Î´Ö¤Ç³Ñ³ç¸Ì¤¬Âбþ¤·¤Æ¤¤¤ì¤Ð¤Á¤ã¤ó¤ÈÆ°ºî¤¹¤ë¡£
180 .\"O .SS Repeated Characters
182 .\"O The notation `\fB[\fIC\fB*\fIN\fB]\fR' in \fISET2\fR expands to \fIN\fR
183 .\"O copies of character \fIC\fR. Thus, `[y*6]' is the same as `yyyyyy'. The
184 .\"O notation `[C*]' in \fISTRING2\fR expands to as many copies of C as are
185 .\"O needed to make \fISET2\fR as long as \fISET1\fR. If \fIN\fR begins with
186 .\"O `0', it is interpreted in octal, otherwise in decimal.
187 \fISET2\fP ¤Ë¤ª¤±¤ë `\fB[\fIC\fP*\fIN\fB]\fR' ¤È¤¤¤Ã¤¿É½µ¤Ï
188 \fIN\fP ¸Ä¤Îʸ»ú \fIC\fP ¤ËŸ³«¤µ¤ì¤ë¡£
189 ¤·¤¿¤¬¤Ã¤Æ `[y*6]' ¤Ï `yyyyyy' ¤Ë¤Ê¤ë¡£
190 \fISET2\fP ¤Ë¤ª¤±¤ë `[\fIC\fP*]' ¤Ï \fISET2\fP ¤ò \fISET1\fP
191 ¤ÈƱ¤¸Ä¹¤µ¤Ë¤¹¤ë¤¿¤á¤ËɬÍפʸĿô¤Îʸ»ú \fIC\fP ¤ËŸ³«¤µ¤ì¤ë¡£
192 \fIN\fP ¤¬ 0 ¤Ç¤Ï¤¸¤Þ¤ë¾ì¹ç¤Ï 8 ¿Ê¿ô¤È¤ß¤Ê¤µ¤ì¡¢
193 ¤½¤ì°Ê³°¤Î¾ì¹ç¤Ï 10 ¿Ê¿ô¤È¤ß¤Ê¤µ¤ì¤ë¡£
194 .\"O .SS Character Classes
196 .\"O The notation `\fB[:\fICLASS\fB:]\fR' expands to all of the
197 .\"O characters in the
198 .\"O (predefined) class \fICLASS\fR. The characters expand in no particular
199 .\"O order, except for the \fBupper\fR and \fBlower\fR classes, which expand in
200 .\"O ascending order. When the \fB\-\-delete\fR and \fB\-\-squeeze\-repeats\fR
201 .\"O options are both given, any character class can be used in \fISET2\fR.
202 .\"O Otherwise, only the character classes \fBlower\fR and \fBupper\fR are
203 .\"O accepted in \fISET2\fR, and then only if the corresponding character class
204 .\"O (\fBupper\fR and \fBlower\fR, respectively) is specified in the same
205 .\"O relative position in \fISET1\fR. Doing this specifies case conversion. The
206 .\"O class names are given below; an error results when an invalid class name is
208 `\fB[:\fICLASS\fB:]\fR' ¤È¤¤¤Ã¤¿É½µ¤Ï¡¢
209 ¤¢¤é¤«¤¸¤áÄêµÁ¤µ¤ì¤¿Ê¸»ú¥¯¥é¥¹ \fICLASS\fP ¤Î¤¹¤Ù¤Æ¤Îʸ»ú¤ËŸ³«¤µ¤ì¤ë¡£
210 ʸ»ú¥¯¥é¥¹¤Ë¤ÏÆÃÄê¤Î½ç½ø¤ÏÄêµÁ¤µ¤ì¤Æ¤¤¤Ê¤¤¡£
211 ¤¿¤À¤· `upper' ¤È `lower' ¥¯¥é¥¹¤Î¤ß¤ÏÎã³°¤Ç¡¢¾º½ç¤ËŸ³«¤µ¤ì¤ë¡£
212 .BR \-\-delete " (" \-d )
214 .BR \-\-squeeze\-repeats " (" \-s )
215 ¤ÎξÊý¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¤Ï¡¢
216 \fISET2\fP ¤Ë¤Ï¤É¤ó¤Êʸ»ú¥¯¥é¥¹¤Ç¤âÍѤ¤¤ë¤³¤È¤¬¤Ç¤¤ë¡£
217 ¤½¤ì°Ê³°¤Î¾ì¹ç¤Ï¡¢ \fISET2\fP ¤Ë»ØÄê¤Ç¤¤ë¤Î¤Ï `lower' ¤ª¤è¤Ó `upper' ¤Î¤ß¤Ç¡¢
218 ¤·¤«¤â¤½¤ì¤¾¤ì¤ËÂбþ¤¹¤ë¥¯¥é¥¹
219 (`lower' ¤Ë¤Ï `upper'¡¢ `upper' ¤Ë¤Ï `lower') ¤¬
220 \fISET1\fP ¤ÎƱ¤¸°ÌÃ֤˻ØÄꤵ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
221 ¤³¤Î¾ì¹ç¤ÏÂçʸ»ú¾®Ê¸»ú¤¬ÊÑ´¹¤µ¤ì¤ë¡£
222 ʸ»ú¥¯¥é¥¹Ì¾¤ò°Ê²¼¤Ë¼¨¤¹¡£
223 ¤³¤ì¤é°Ê³°¤Î̾Á°¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¤Ë¤Ï¥¨¥é¡¼¤È¤Ê¤ë¡£
227 .\"O Letters and digits
235 .\"O Horizontal whitespace
236 ¿åÊ¿Êý¸þ¤Î¶õÇò (Horizontal whitespace)
239 .\"O Control characters
247 .\"O Printable characters, not including space
248 °õºþ¤Ç¤¤ëʸ»ú (¶õÇò¤Ï´Þ¤Þ¤Ê¤¤)
251 .\"O Lowercase letters
255 .\"O Printable characters, including space
256 °õºþ¤Ç¤¤ëʸ»ú (¶õÇò¤â´Þ¤à)
259 .\"O Punctuation characters
263 .\"O Horizontal or vertical whitespace
264 ¿åÊ¿¤ª¤è¤Ó¿âľÊý¸þ¤Î¶õÇò
267 .\"O Uppercase letters
271 .\"O Hexadecimal digits
274 .\"O .SS Equivalence Classes
276 .\"O The syntax `\fB[=\fIC\fB=]\fR' expands to all of the characters that are
277 .\"O equivalent to \fIC\fR, in no particular order. Equivalence classes are
278 .\"O a relatively recent invention intended to support non-English alphabets.
279 .\"O But there seems to be no standard way to define them or determine their
280 .\"O contents. Therefore, they are not fully implemented in GNU \fBtr\fR; each
281 .\"O character's equivalence class consists only of that character, which is of
282 .\"O no particular use.
283 `\fB[=\fIC\fB=]\fR' ¤È¤¤¤Ã¤¿É½µ¤Ï¡¢
284 \fIC\fP ¤ÈÅù²Á¤Êʸ»ú¤ËŸ³«¤µ¤ì¤ë¡£¤³¤Î¤È¤½ç½ø¤ÏÄêµÁ¤µ¤ì¤Ê¤¤¡£
285 Åù²Á¥¯¥é¥¹¤Ï¡¢±Ñ¸ì°Ê³°¤Î¥¢¥ë¥Õ¥¡¥Ù¥Ã¥È¤ò¥µ¥Ý¡¼¥È¤¹¤ë¤¿¤á¤Ë
286 ºÇ¶áȯÌÀ¤µ¤ì¤¿¤â¤Î¤Ç¤¢¤ë¡£
287 ¤·¤«¤·¸½ºß¤Î¤È¤³¤í¤³¤ì¤é¤ÎÄêµÁ¤äÆâÍÆ»ØÄê¤Ëɸ½àŪ¤ÊÊýË¡¤Ï¤Ê¤¤¤è¤¦¤Ç¤¢¤ë¡£
290 ¤Ç¤â´°Á´¤Ë¤Ï¼ÂÁõ¤µ¤ì¤Æ¤¤¤Ê¤¤¡£
291 ¤½¤ì¤¾¤ì¤Îʸ»ú¤ÎÅù²Á¥¯¥é¥¹¤Ï¤½¤Îʸ»ú¤«¤é¤Î¤ß¹½À®¤µ¤ì¤Æ¤¤¤ë¡£
292 ¤·¤¿¤¬¤Ã¤Æ¤³¤Îµ¡Ç½¤Ï¸½ºß¤Î¤È¤³¤íÌò¤ËΩ¤¿¤Ê¤¤¡£
295 .\"O \fBtr\fR performs translation when \fISET1\fR and \fISET2\fR are both given and
296 .\"O \fB\-\-delete\fR is not specified. \fRtr\fN translates each character
297 .\"O of its input that is in \fISET1\fR to the corresponding character in \fISET2\fR.
298 .\"O Characters not in \fISET1\fR are passed through unchanged. When a character
299 .\"O appears more than once in \fISET1\fR and the corresponding characters in \fISET2\fR
300 .\"O are not all the same, only the final one is used. For example, these
301 .\"O two commands are equivalent:
303 ¤Ï \fISET1\fP ¤È \fISET2\fP ¤ÎξÊý¤¬»ØÄꤵ¤ì¤Æ¤¤¤Æ¡¢
304 .BR \-\-delete " (" \-d )
305 ¥ª¥×¥·¥ç¥ó¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ë¤ÏÊÑ´¹¤ò¹Ô¤¦¡£
307 ¤ÏÆþÎϤΤ¦¤Á \fISET1\fR ¤Ë¤¢¤ëʸ»ú¤ò
308 \fISET2\fR ¤ÎÂбþ¤¹¤ë°ÌÃ֤ˤ¢¤ëʸ»ú¤ËÊÑ´¹¤¹¤ë¡£
309 \fISET1\fR ¤Ë̵¤¤Ê¸»ú¤Ï¤½¤Î¤Þ¤Þ½ÐÎϤµ¤ì¤ë¡£
310 ¤â¤·Ê¸»ú¤¬ \fISET1\fR ¤Ë 2 ²ó°Ê¾å¸½¤ï¤ì¡¢
311 \fISET2\fR ¤ÎÂбþ¤¹¤ëʸ»ú¤¬¤¹¤Ù¤ÆƱ¤¸¤Ç¤Ê¤¤¾ì¹ç¤Ë¤Ï¡¢
312 ºÇ¸å¤Îʸ»ú¤À¤±¤¬»È¤ï¤ì¤ë¡£Î㤨¤Ð°Ê²¼¤ÎÆó¤Ä¤Î¥³¥Þ¥ó¥É¤ÏÅù²Á¤Ç¤¢¤ë:
321 .\"O A common use of \fBtr\fR is to convert lowercase characters to
322 .\"O uppercase. This can be done in many ways. Here are three of them:
324 ¤ÎÎɤ¯¤¢¤ë»È¤¤Êý¤È¤·¤Æ¤Ï¡¢±Ñ¾®Ê¸»ú¤ÎÂçʸ»ú¤Ø¤ÎÊÑ´¹¤¬¤¢¤²¤é¤ì¤ë¡£
325 ¤¤¤í¤¤¤í¤Ê¤ä¤êÊý¤¬²Äǽ¤Ç¤¢¤ë¤¬¡¢°Ê²¼¤ËÎã¤ò 3 ¤Ä¼¨¤¹¡£
329 tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
331 tr '[:lower:]' '[:upper:]'
335 .\"O When \fBtr\fR is performing translation, \fISET1\fR and \fISET2\fR typically have
336 .\"O the same length. If \fISET1\fR is shorter than \fISET2\fR, the extra characters at
337 .\"O the end of \fISET2\fR are ignored.
339 ¤¬ÊÑ´¹¤ò¹Ô¤¦ºÝ¤Ë¤Ï¡¢ \fISET1\fR ¤È \fISET2\fR ¤ÏÄ̾ïƱ¤¸Ä¹¤µ¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
340 \fISET1\fR ¤¬ \fISET2\fR ¤è¤êû¤¤¾ì¹ç¤Ë¤Ï¡¢ \fISET2\fR ¤ÎÈøÉô¤Î;¤ê¤Ï̵»ë¤µ¤ì¤ë¡£
342 .\"O On the other hand, making \fISET1\fR longer than \fISET2\fR is not portable;
343 .\"O POSIX.2 says that the result is undefined. In this situation, BSD \fBtr\fR
344 .\"O pads \fISET2\fR to the length of \fISET1\fR by repeating the last character
345 .\"O of \fISET2\fR as many times as necessary. System V \fBtr\fR truncates
346 .\"O \fBSET1\fR to the length of \fBSET2\fR.
347 µÕ¤Ë \fISET1\fR ¤ò \fISET2\fR ¤è¤êŤ¯»ØÄꤹ¤ë¤È¡¢Æ°ºî¤Ïͽ¬¤Ç¤¤Ê¤¯¤Ê¤ë¡£
348 POSIX.2 ¤Ë¤è¤ì¤Ð¡¢·ë²Ì¤ÏÄêµÁ¤µ¤ì¤Ê¤¤¡£
349 ¤³¤Î¤è¤¦¤Ê¾ì¹ç¡¢ BSD ÈÇ
351 ¤Ç¤Ï \fISET2\fR ¤Î¤ê¤Ê¤¤Éôʬ¤òºÇ¸å¤Îʸ»ú¤ÇËä¤á¡¢ \fISET1\fR ¤ÈƱ¤¸Ä¹¤µ¤Ë¤¹¤ë¡£
354 ¤Ï \fISET1\fR ¤ÎÈøÉô¤òÀÚ¤ê¼Î¤Æ¤Æ \fISET2\fR ¤ÈƱ¤¸Ä¹¤µ¤Ë¤¹¤ë¡£
356 .\"O By default, GNU \fBtr\fR handles this case like BSD \fBtr\fR. When the
357 .\"O \fB\-\-truncate\-set1\fR option is given, GNU \fBtr\fR handles this case
358 .\"O like the System V \fBtr\fR instead. This option is ignored for operations
359 .\"O other than translation. Acting like System V \fBtr\fR in this case breaks the
360 .\"O relatively common BSD idiom:
361 ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï GNU ÈÇ
365 ¤ÈƱ¤¸¤è¤¦¤Ë¿¶¤ëÉñ¤¦¡£
366 ¤Þ¤¿ \-\-truncate\-set1 (\fI\-t\fP) ¥ª¥×¥·¥ç¥ó¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¤Ë¤Ï¡¢
371 ¤Î¤è¤¦¤Ë¿¶¤ëÉñ¤¦¡£¤³¤Î¥ª¥×¥·¥ç¥ó¤ÏÊÑ´¹°Ê³°¤ÎÅÀ¤Ë´Ø¤·¤Æ¤Ï̵»ë¤µ¤ì¤ë¡£
374 Ū¤Ê¿¶¤ëÉñ¤¤¤Î²¼¤Ç¤Ï¡¢ BSD ÈǤÎÍ̾¤ÊÍÑË¡:
378 tr \-cs A\-Za\-z0\-9 '\e012'
382 .\"O because it converts only zero bytes (the first element in the
383 .\"O complement of \fISET1\fR), rather than all non-alphanumerics, to newlines.
384 ¤Ï»È¤¨¤Ê¤¯¤Ê¤ë¡£¤³¤ì¤Ï¥¢¥ë¥Õ¥¡¥Ù¥Ã¥Èʸ»ú¤ª¤è¤Ó¿ô»ú°Ê³°¤Îʸ»ú¤ò²þ¹Ôʸ»ú
385 ¤ËÃÖ´¹¤¹¤ë¤â¤Î¤Ç¤¢¤ë¤¬¡¢ System V ¤Ç¤ÏÆâÍƤ¬ 0 ¤Î¥Ð¥¤¥È
386 (\fISET1\fR ¤ÎÊ佸¹ç¤ÎÀèƬÍ×ÁÇ) ¤Î¤ß¤òÊÑ´¹¤¹¤ë¤³¤È¤Ë¤Ê¤ë¡£
387 .\"O .SH SQUEEZING REPEATS AND DELETING
388 .SH ·«¤êÊÖ¤·¤Î°µ½Ì¤Èºï½ü
389 .\"O When given just the \fB\-\-delete\fR option, \fBtr\fR removes any input
390 .\"O characters that are in \fISET1\fR.
391 .BR \-\-delete " (" \-d )
392 ¥ª¥×¥·¥ç¥ó¤À¤±¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¤Ï¡¢
394 ¤ÏÆþÎϤΤ¦¤Á \fISET1\fR ¤Ë¤¢¤ëʸ»ú¤òºï½ü¤¹¤ë¡£
396 .\"O When given just the \fB\-\-squeeze\-repeats\fR option, \fBtr\fR replaces
397 .\"O each input sequence of a repeated character that is in \fISET1\fR with a
398 .\"O single occurrence of that character.
399 .BR \-\-squeeze\-repeats " (" \-s )
400 ¥ª¥×¥·¥ç¥ó¤À¤±¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¤Ë¤Ï¡¢
402 ¤ÏÆþÎϤΤ¦¤Á¡¢ \fISET1\fR ¤Ë¤¢¤ëʸ»ú¤Î·«¤êÊÖ¤·¤ò¡¢¤½¤Îʸ»ú 1 ʸ»ú¤ËÃÖ¤´¹¤¨¤ë¡£
404 .\"O When given both \fB\-\-delete\fR and \fB\-\-squeeze\-repeats\fR, \fBtr\fR
405 .\"O first performs any deletions using \fISET1\fR, then squeezes repeats from any
406 .\"O remaining characters using \fISET2\fR.
407 .BR \-\-delete " ¤È " \-\-squeeze\-repeats
408 ¤ÎξÊý¤Î¥ª¥×¥·¥ç¥ó¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¤Ë¤Ï¡¢
410 ¤Ï¤Þ¤º \fISET1\fR ¤Ë¤¢¤ëʸ»ú¤òºï½ü¤·¡¢
411 »Ä¤ê¤Î¤¦¤Á \fISET2\fR ¤Ë¤¢¤ëʸ»ú¤Î·«¤êÊÖ¤·¤ò°µ½Ì¤¹¤ë¡£
413 .\"O The \fB\-\-squeeze\-repeats\fR option may also be used when translating, in
414 .\"O which case tr' first performs translation, then squeezes repeats from
415 .\"O any remaining characters using \fISET2\fR.
416 .B \-\-squeeze\-repeats
417 ¥ª¥×¥·¥ç¥ó¤ÏÊÑ´¹¤È¶¦¤ËÍѤ¤¤ë¤³¤È¤â¤Ç¤¤ë¡£¤³¤Î¾ì¹ç¤Ë¤Ï
419 ¤Ï¤Þ¤ºÊÑ´¹¤ò¹Ô¤¤¡¢»Ä¤ê¤Îʸ»ú¤Î¤¦¤Á \fISET2\fR ¤Ë¤¢¤ë¤â¤Î¤ò°µ½Ì¤¹¤ë¡£
421 .\"O Here are some examples to illustrate various combinations of options:
422 °Ê²¼¤Ë¤³¤ì¤é¤Î¥ª¥×¥·¥ç¥ó¤òÁȤ߹ç¤ï¤»¤¿ÍøÍÑÎã¤ò¼¨¤¹:
424 .\"O \fB\(bu\fR Remove all zero bytes
425 \fB\(bu\fR ÆâÍƤ¬ 0 ¤Î¥Ð¥¤¥È¤òºï½ü¤¹¤ë:
433 .\"O \fB\(bu\fR Put all words on lines by themselves. This converts all
434 .\"O non-alphanumeric characters to newlines, then squeezes each string
435 .\"O of repeated newlines into a single newline
436 \fB\(bu\fR ¤¹¤Ù¤Æ¤Îñ¸ì¤ò¤½¤ì¼«¿È¤Î¤ß¤«¤é¤Ê¤ë¹Ô¤ËÊÑ´¹¤¹¤ë¡£
437 ¤Ä¤Þ¤ê¥¢¥ë¥Õ¥¡¥Ù¥Ã¥Èʸ»ú¡¢¿ô»ú°Ê³°¤Îʸ»ú¤ò²þ¹Ôʸ»ú¤ËÊÑ´¹¤·¡¢
438 ²þ¹Ôʸ»ú¤Î·«¤êÊÖ¤·¤ò°ì¤Ä¤Î²þ¹Ôʸ»ú¤Ë°µ½Ì¤¹¤ë:
442 tr \-cs '[a\-zA\-Z0\-9]' '[\en*]'
446 .\"O \fB\(bu\fR Convert each sequence of repeated newlines to a single newline
447 \fB\(bu\fR ²þ¹Ôʸ»ú¤Î·«¤êÊÖ¤·¤ò°ì¤Ä¤Î²þ¹Ôʸ»ú¤ËÊÑ´¹¤¹¤ë¡£
455 .\"O \fB\(bu\fR Find doubled occurrences of words in a document. For example,
456 .\"O people often write "the the" with the duplicated words separated by a
457 .\"O newline. The bourne shell script below works first by converting each
458 .\"O sequence of punctuation and blank characters to a single newline. That puts
459 .\"O each "word" on a line by itself. Next it maps all uppercase characters to
460 .\"O lower case, and finally it runs \fBuniq\fR(1) with the \fB\-d\fR option to
461 .\"O print out only the words that were adjacent duplicates.
462 \fB\(bu\fR ʸ½ñÃæ¤ÎƱ¤¸Ã±¸ì¤ÎϢ³¤ò¸«¤Ä¤±¤ë¡£Î㤨¤Ð
463 "the the" ¤Î¤è¤¦¤Ë¡¢²þ¹Ô¤ò¶´¤ó¤Çñ¸ì¤ò¥À¥Ö¤Ã¤Æ½ñ¤¤¤Æ¤·¤Þ¤¦¤³¤È¤¬¤è¤¯¤¢¤ë¡£
464 °Ê²¼¤Î bourne ¥·¥§¥ë¥¹¥¯¥ê¥×¥È¤Ï¡¢¤Þ¤º¶çÆÉÅÀ¤ä¶õÇò¤ÎϢ³¤ò²þ¹Ô¤ËÊÑ´¹¤¹¤ë¡£
465 ¤³¤ì¤Ë¤è¤Ã¤Æ¡¢³Æ¡Öñ¸ì¡×¤Ï¡¢¤½¤ì¤¾¤ì¼«Ê¬¼«¿È¤À¤±¤«¤é¤Ê¤ë¹Ô¤ËÃÖ¤«¤ì¤ë¡£
466 ¼¡¤ËÂçʸ»ú¤ò¾®Ê¸»ú¤ËÊÑ´¹¤·¡¢ºÇ¸å¤Ë
470 ¥ª¥×¥·¥ç¥ó¤Çµ¯Æ°¤·¤Æ¡¢Ï¢Â³¤·¤¿Æ±¤¸Ã±¸ì¤À¤±¤òɽ¼¨¤¹¤ë¡£
476 | tr \-s '[:punct:][:blank:]' '\en' \e
477 | tr '[:upper:]' '[:lower:]' \e
482 .\"O .SH COMPATIBILITY
484 .\"O Setting the environment variable \fBPOSIXLY_CORRECT\fR turns off the
485 .\"O following warning and error messages, for strict compliance with
486 .\"O POSIX.2. Otherwise, the following diagnostics are issued:
489 ¤ò»ØÄꤹ¤ë¤È¡¢ POSIX.2 ¤È¤Î¸·Ì©¤Ê¸ß´¹À¤ò¤È¤ë¤¿¤á¤Ë¡¢
490 ·Ù¹ð¤ª¤è¤Ó¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤Î¤¤¤¯¤Ä¤«¤¬½ÐÎϤµ¤ì¤Ê¤¯¤Ê¤ë¡£
491 »ØÄꤷ¤Ê¤±¤ì¤Ð¡¢°Ê²¼¤Î¤è¤¦¤Ê¾ì¹ç¤Ë¥á¥Ã¥»¡¼¥¸¤¬½Ð¤ë¡£
493 .\"O 1. When the \fB\-\-delete\fR option is given but \fB\-\-squeeze\-repeats\fR is
494 .\"O not, and \fISET2\fR is given, GNU \fBtr\fR by default prints a usage message
495 .\"O and exits, because \fISET2\fR would not be used. The POSIX specification
496 .\"O says that \fISET2\fR must be ignored in this case. Silently ignoring
497 .\"O arguments is a bad idea.
500 ¥ª¥×¥·¥ç¥ó¤¬»ØÄꤵ¤ì¤Æ¤¤¤ë¤¬
501 .B \-\-squeeze\-repeats
502 ¤¬»ØÄꤵ¤ì¤Æ¤ª¤é¤º¡¢¤«¤Ä \fISET2\fP ¤¬Í¿¤¨¤é¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï¡¢GNU ÈÇ
504 ¤Ï¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï»ÈÍÑË¡¤Î¥á¥Ã¥»¡¼¥¸¤òɽ¼¨¤·¤Æ½ªÎ»¤¹¤ë¡£
505 ¤Ê¤¼¤Ê¤é¤³¤Î¤È¤ \fISET2\fP ¤ÏÍøÍѤµ¤ì¤Ê¤¤¤«¤é¤Ç¤¢¤ë¡£
506 ¤·¤«¤· POSIX µ¬³Ê¤Ë¤è¤ì¤Ð¡¢
507 ¤³¤Î¾ì¹ç¤Ï \fISET2\fP ¤Ïñ¤Ë̵»ë¤µ¤ì¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
508 °ú¤¿ô¤òÌۤäÆ̵»ë¤¹¤ë¤Î¤ÏÎɤ¯¤Ê¤¤»ÅÍͤÀ¤È»×¤¦¤Î¤À¤¬¡£
510 .\"O 2. When an ambiguous octal escape is given. For example, `\400' is
511 .\"O actually \40' followed by the digit `0', because the value 400
512 .\"O octal does not fit into a single byte.
514 ¤¢¤¤¤Þ¤¤¤Ê 8 ¿Ê¿ô¥¨¥¹¥±¡¼¥×¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¡£Î㤨¤Ð `\e400' ¤Ï¼ÂºÝ¤Ë
515 ¤Ï \e40 ¤È¿ô»ú 0 ¤ÎʤӤȲò¼á¤µ¤ì¤ë¡£
516 ¤Ê¤¼¤Ê¤é 8 ¿Ê¿ô¤Î 400 ¤ËÂбþ¤¹¤ë¥Ð¥¤¥È¤Ï¸ºß¤·¤Ê¤¤¤«¤é¤Ç¤¢¤ë¡£
518 .\"O GNU \fBtr\fR does not provide complete BSD or System V compatibility.
519 .\"O For example, it is impossible to disable interpretation of the POSIX
520 .\"O constructs `[:alpha:]', `[=c=]', and `[c*10]'. Also, GNU \fBtr\fR does not
521 .\"O delete zero bytes automatically, unlike traditional Unix versions,
522 .\"O which provide no way to preserve zero bytes.
525 ¤Ï BSD ¤ä System V ¤È¸ß´¹¤Ç¤Ï¤Ê¤¤¡£
526 Îã¤òµó¤²¤ì¤Ð¡¢ POSIX ÄêµÁ¤Ë¤¢¤ë `[:alpha:]', `[=c=]', `[c*10]'
527 ¤È¤¤¤Ã¤¿»ØÄê¤Î²ò¼á¤ò»ß¤á¤µ¤»¤ë¤è¤¦¤Ê¥ª¥×¥·¥ç¥ó¤Ï¸ºß¤·¤Ê¤¤¡£
530 ¤ÏÆâÍƤ¬ 0 ¤Î¥Ð¥¤¥È¤ò¼«Æ°Åª¤Ë¤Ïºï½ü¤·¤Ê¤¤¡£
531 °ìÊý¤³¤ì¤Þ¤Ç¤Î UNIX ÈǤǤϡ¢¤³¤Î¥Ð¥¤¥È¤ò»Ä¤¹ÊýË¡¤ÎÊý¤¬Â¸ºß¤·¤Ê¤¤¡£
534 .\"O Report bugs to bug-textutils@gnu.org.
536 .\"O Man page by Ragnar Hojland Espinosa <ragnar@ragnar-hojland.com>
537 ¥×¥í¥°¥é¥à¤Î¥Ð¥°¤Ë¤Ä¤¤¤Æ¤Ï bug-textutils@gnu.org ¤ËÊó¹ð¤·¤Æ¤¯¤À¤µ¤¤¡£
539 man ¥Ú¡¼¥¸¤Ï Ragnar Hojland Espinosa <ragnar@ragnar-hojland.com> ¤¬ºîÀ®¤·¤Þ¤·¤¿¡£