OSDN Git Service

(split) LDP v3.24 -> v3.29 の定型的な変更内容を反映。
[linuxjm/LDP_man-pages.git] / draft / man7 / glob.7
1 .\" Copyright (c) 1998 Andries Brouwer
2 .\"
3 .\" This is free documentation; you can redistribute it and/or
4 .\" modify it under the terms of the GNU General Public License as
5 .\" published by the Free Software Foundation; either version 2 of
6 .\" the License, or (at your option) any later version.
7 .\"
8 .\" The GNU General Public License's references to "object code"
9 .\" and "executables" are to be interpreted as the output of any
10 .\" document formatting or typesetting system, including
11 .\" intermediate and printed output.
12 .\"
13 .\" This manual is distributed in the hope that it will be useful,
14 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
15 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 .\" GNU General Public License for more details.
17 .\"
18 .\" You should have received a copy of the GNU General Public
19 .\" License along with this manual; if not, write to the Free
20 .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
21 .\" USA.
22 .\"
23 .\" 2003-08-24 fix for / by John Kristoff + joey
24 .\"
25 .\" Japanese Version Copyright (c) 1998 NAKANO Takeo all rights reserved.
26 .\" Translated Wed 12 Aug 1998 by NAKANO Takeo <nakano@apm.seikei.ac.jp>
27 .\" Updated 2003-09-28 by NAKANO Takeo
28 .\"
29 .\"WORD:        wild card pattern       ¥ï¥¤¥ë¥É¥«¡¼¥É¥Ñ¥¿¡¼¥ó
30 .\"WORD:        character class         Ê¸»ú¥¯¥é¥¹
31 .\"WORD:        range                   Îΰè»ØÄê
32 .\"WORD:        complementation         Ê佸¹ç
33 .\"WORD:        regular expression      Àµµ¬É½¸½
34 .\"WORD:        bracket expression      ¥Ö¥é¥±¥Ã¥Èɽ¸½
35 .\"WORD:        collating sequence      ¾È¹ç½ç½ø
36 .\"WORD:        collating element       ¾È¹ç½ç½ø¤ÎÍ×ÁÇ
37 .\"WORD:        current locale          ¥«¥ì¥ó¥È¥í¥±¡¼¥ë
38 .\"WORD:        equivalence class       Åù²Á¥¯¥é¥¹
39 .\"
40 .TH GLOB 7 2003-08-24 "Linux" "Linux Programmer's Manual"
41 .\"O .SH NAME
42 .SH Ì¾Á°
43 .\"O glob \- Globbing pathnames
44 glob \- ¥Ñ¥¹Ì¾¤ò glob ¤¹¤ë
45 .\"O .SH DESCRIPTION
46 .SH ÀâÌÀ
47 .\"O Long ago, in UNIX V6, there was a program
48 .\"O .I /etc/glob
49 .\"O that would expand wildcard patterns.
50 .\"O Soon afterward this became a shell built-in.
51 ÀΡ¹ UNIX V6 ¤Ç¤Ï¡¢¥ï¥¤¥ë¥É¥«¡¼¥É¥Ñ¥¿¡¼¥ó¤òŸ³«¤¹¤ë
52 .I /etc/glob
53 ¤È¸À¤¦¥×¥í¥°¥é¥à¤¬¤¢¤Ã¤¿¡£¤½¤Î¸å¤¹¤°¤Ë¡¢
54 ¤³¤Îµ¡Ç½¤Ï¥·¥§¥ë¤ËÁȤ߹þ¤Þ¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡£
55
56 .\"O These days there is also a library routine
57 .\"O .BR glob (3)
58 .\"O that will perform this function for a user program.
59 º£Æü¤Ç¤Ï¡¢¤³¤Îµ¡Ç½¤ò¥æ¡¼¥¶¡¼¥×¥í¥°¥é¥à¤«¤é¤â¼Â¹Ô¤Ç¤­¤ë¤è¤¦¡¢
60 .BR glob (3)
61 ¤È¤¤¤¦¥é¥¤¥Ö¥é¥ê¥ë¡¼¥Á¥ó¤â¸ºß¤·¤Æ¤¤¤ë¡£
62
63 .\"O The rules are as follows (POSIX.2, 3.13).
64 glob ¤Îµ¬Â§¤ò°Ê²¼¤Ë½Ò¤Ù¤ë (POSIX.2 3.13)¡£
65 .\"O .SS "Wildcard Matching"
66 .SS ¥ï¥¤¥ë¥É¥«¡¼¥É¥Þ¥Ã¥Á
67 .\"O A string is a wildcard pattern if it contains one of the
68 .\"O characters \(aq?\(aq, \(aq*\(aq or \(aq[\(aq.
69 .\"O Globbing is the operation
70 .\"O that expands a wildcard pattern into the list of pathnames
71 .\"O matching the pattern.
72 .\"O Matching is defined by:
73 ʸ»úÎó¤Ë \(aq?\(aq, \(aq*\(aq, \(aq[\(aq ¤¬´Þ¤Þ¤ì¤Æ¤¤¤ë¤È¡¢
74 ¤½¤ì¤Ï¥ï¥¤¥ë¥É¥«¡¼¥É¥Ñ¥¿¡¼¥ó¤È¤ß¤Ê¤µ¤ì¤ë¡£
75 ¡Öglob ¤¹¤ë¡×¤È¤¤¤¦¤Î¤Ï¡¢¥ï¥¤¥ë¥É¥«¡¼¥É¥Ñ¥¿¡¼¥ó¤òŸ³«¤·¤Æ¡¢
76 ¤½¤Î¥Ñ¥¿¡¼¥ó¤Ë¥Þ¥Ã¥Á¤¹¤ë¥Ñ¥¹Ì¾¤Î¥ê¥¹¥È¤òÆÀ¤ë¤³¤È¤Ç¤¢¤ë¡£
77 ¥Þ¥Ã¥Á¤Ï°Ê²¼¤Î¤è¤¦¤ËÄêµÁ¤µ¤ì¤ë¡£
78
79 .\"O A \(aq?\(aq (not between brackets) matches any single character.
80 (¥Ö¥é¥±¥Ã¥È³°Éô¤Î) \(aq?\(aq ¤Ï¤¢¤é¤æ¤ëñ°ì¤Îʸ»ú¤Ë¥Þ¥Ã¥Á¤¹¤ë¡£
81
82 .\"O A \(aq*\(aq (not between brackets) matches any string,
83 .\"O including the empty string.
84 (¥Ö¥é¥±¥Ã¥È³°Éô¤Î) \(aq*\(aq ¤Ï¤¢¤é¤æ¤ëʸ»úÎó¤Ë¥Þ¥Ã¥Á¤¹¤ë¡£
85 ¶õʸ»úÎó (empty string) ¤Ë¤â¥Þ¥Ã¥Á¤¹¤ë¡£
86 .PP
87 .\"O .B "Character classes"
88 .B "ʸ»ú¥¯¥é¥¹ (character class)"
89 .sp
90 .\"O An expression "\fI[...]\fP" where the first character after the
91 .\"O leading \(aq[\(aq is not an \(aq!\(aq matches a single character,
92 .\"O namely any of the characters enclosed by the brackets.
93 .\"O The string enclosed by the brackets cannot be empty;
94 .\"O therefore \(aq]\(aq can be allowed between the brackets, provided
95 .\"O that it is the first character.
96 .\"O (Thus, "\fI[][!]\fP" matches the
97 .\"O three characters \(aq[\(aq, \(aq]\(aq and \(aq!\(aq.)
98 "\fI[...]\fP" ¤È¸À¤¦É½µ­¤Ï¡¢ÀèƬ¤Î \(aq[\(aq ¤Ë³¤¯ºÇ½é¤Îʸ»ú¤¬ \(aq!\(aq ¤Ç
99 ¤Ê¤±¤ì¤Ð¡¢¥Ö¥é¥±¥Ã¥È¤ÎÃæ¤Ë´Þ¤Þ¤ì¤Æ¤¤¤ëʸ»ú¤Î¤É¤ì¤«°ì¤Ä¤Ë¥Þ¥Ã¥Á¤¹¤ë¡£
100 ¥Ö¥é¥±¥Ã¥È¤ÎÆâÉô¤Ë´Þ¤Þ¤ì¤ëʸ»úÎó¤Ï¶õ¤Ç¤¢¤Ã¤Æ¤Ï¤Ê¤é¤Ê¤¤¡£
101 ¤·¤¿¤¬¤Ã¤Æ \(aq]\(aq ¤âºÇ½é¤Îʸ»ú¤Ë»ØÄꤹ¤ì¤Ð¥Ö¥é¥±¥Ã¥È¤ÎÆâÉô¤Ë´Þ¤á¤ë¤³¤È¤¬
102 ¤Ç¤­¤ë (¤Ä¤Þ¤ê "\fI[][!]\fP" ¤Ï \(aq[\(aq, \(aq]\(aq, \(aq!\(aq ¤Î
103 3 Ê¸»ú¤Î¤É¤ì¤«¤Ë¥Þ¥Ã¥Á¤¹¤ë)¡£
104 .PP
105 .\"O .B Ranges
106 .B "Îΰè»ØÄê (range)"
107 .sp
108 .\"O There is one special convention:
109 .\"O two characters separated by \(aq\-\(aq denote a range.
110 .\"O (Thus, "\fI[A\-Fa\-f0\-9]\fP"
111 .\"O is equivalent to "\fI[ABCDEFabcdef0123456789]\fP".)
112 .\"O One may include \(aq\-\(aq in its literal meaning by making it the
113 .\"O first or last character between the brackets.
114 .\"O (Thus, "\fI[]\-]\fP" matches just the two characters \(aq]\(aq and \(aq\-\(aq,
115 .\"O and "\fI[\-\-0]\fP" matches the
116 .\"O three characters \(aq\-\(aq, \(aq.\(aq, \(aq0\(aq, since \(aq/\(aq
117 .\"O cannot be matched.)
118 Æüì¤Êɽµ­Ë¡¤¬°ì¤Ä¸ºß¤¹¤ë¡£\(aq\-\(aq ¤ò¶´¤àÆó¤Ä¤Îʸ»ú¤ÏÎΰè»ØÄê¤È¤Ê¤ë¡£
119 (¤Ä¤Þ¤ê "\fI[A\-Fa\-f0\-9]\fP" ¤Ï "\fI[ABCDEFabcdef0123456789]\fP"
120 ¤ÈÅù²Á¤È¤Ê¤ë¡£) \(aq\-\(aq Ê¸»ú¤½¤Î¤â¤Î¤òÆþ¤ì¤¿¤¤¾ì¹ç¤Ï¡¢
121 ¥Ö¥é¥±¥Ã¥È¤ÎÀèƬ¤Þ¤¿¤ÏºÇ¸å¤Îʸ»ú¤Ë»ØÄꤹ¤ì¤Ð¤è¤¤¡£
122 (¤Ä¤Þ¤ê "\fI[]\-]\fP" ¤ÏÆó¤Ä¤Îʸ»ú \(aq]\(aq ¤È \(aq\-\(aq
123 ¤Ë¥Þ¥Ã¥Á¤·¡¢"\fI[\-\-0]\fP" ¤Ï \(aq\-\(aq, \(aq.\(aq, \(aq0\(aq ¤Î
124 3 Ê¸»ú¤Ë¥Þ¥Ã¥Á¤¹¤ë¡£¤³¤Î´Ö¤Î \(aq/\(aq ¤Ë¤Ï¥Þ¥Ã¥Á¤·¤Ê¤¤¡£¸å½Ò¤ò»²¾È¡£)
125 .PP
126 .\"O .B Complementation
127 .B Ê佸¹ç (complementation)
128 .sp
129 .\"O An expression "\fI[!...]\fP" matches a single character, namely
130 .\"O any character that is not matched by the expression obtained
131 .\"O by removing the first \(aq!\(aq from it.
132 .\"O (Thus, "\fI[!]a\-]\fP" matches any
133 .\"O single character except \(aq]\(aq, \(aqa\(aq and \(aq\-\(aq.)
134 "\fI[!...]\fP" ¤È¸À¤¦É½µ­¤Ï¡¢¥Ö¥é¥±¥Ã¥È¤ÎÆâÉô¤Ë´Þ¤Þ¤ì¤Ê¤¤Ã±°ì¤Îʸ»ú¤Ë¥Þ¥Ã¥Á¤¹¤ë
135 (¤¿¤À¤·ÀèƬ¤Ë¤¢¤ë \(aq!\(aq ¤Ï½ü³°)¡£ (¤Ä¤Þ¤ê "\fI[!]a\-]\fP" ¤Ï
136 \(aq]\(aq, \(aqa\(aq, \(aq\-\(aq °Ê³°¤Î¤¹¤Ù¤Æ¤Îʸ»ú¤Î¡¢¤É¤ì¤«°ì¤Ä¤Ë¥Þ¥Ã¥Á¤¹¤ë¡£)
137
138 .\"O One can remove the special meaning of \(aq?\(aq, \(aq*\(aq and \(aq[\(aq by
139 .\"O preceding them by a backslash, or, in case this is part of
140 .\"O a shell command line, enclosing them in quotes.
141 .\"O Between brackets these characters stand for themselves.
142 .\"O Thus, "\fI[[?*\e]\fP" matches the
143 .\"O four characters \(aq[\(aq, \(aq?\(aq, \(aq*\(aq and \(aq\e\(aq.
144 ¥Ð¥Ã¥¯¥¹¥é¥Ã¥·¥å \(aq\e\(aq ¤òÁ°ÃÖ¤¹¤ì¤Ð¡¢ \(aq?\(aq, \(aq*\(aq, \(aq[\(aq
145 ¤ÏÄ̾ï¤Îʸ»ú¤È¤·¤Æ°·¤ï¤ì¤ë¡£
146 ¤Þ¤¿¤Ï¥·¥§¥ë¤Î¥³¥Þ¥ó¥É¥é¥¤¥ó¤Î°ìÉô¤Ë»ØÄꤹ¤ë¾ì¹ç¤Ï¡¢
147 ¥¯¥©¡¼¥È¤Ç°Ï¤Ã¤Æ¤âƱ¤¸¸ú²Ì¤¬ÆÀ¤é¤ì¤ë¡£¥Ö¥é¥±¥Ã¥È¤ÎÆâÉô¤Ç¤Ï¡¢
148 ¤³¤ì¤é¤Îʸ»ú¤Ï¤½¤Îʸ»ú¼«¿È¤À¤±¤ò°ÕÌ£¤¹¤ë¡£
149 ¤¹¤Ê¤ï¤Á "\fI[[?*\e]\fP" ¤Ï \(aq[\(aq, \(aq?\(aq, \(aq*\(aq, \(aq\e\(aq
150 ¤Î¤É¤ì¤«°ìʸ»ú¤Ë¥Þ¥Ã¥Á¤¹¤ë¡£
151 .\"O .SS Pathnames
152 .SS "¥Ñ¥¹Ì¾ (pathname)"
153 .\"O Globbing is applied on each of the components of a pathname
154 .\"O separately.
155 .\"O A \(aq/\(aq in a pathname cannot be matched by a \(aq?\(aq or \(aq*\(aq
156 .\"O wildcard, or by a range like "\fI[.\-0]\fP".
157 .\"O A range cannot contain an
158 .\"O explicit \(aq/\(aq character; this would lead to a syntax error.
159 glob Æ°ºî¤Ï¡¢¥Ñ¥¹Ì¾¤Î¤½¤ì¤¾¤ì¤ÎÉôʬ¤ËÆÈΩ¤ËŬÍѤµ¤ì¤ë¡£
160 ¥Ñ¥¹Ì¾¤Ë¸ºß¤¹¤ë \(aq/\(aq ¤Ï \(aq?\(aq ¤ä \(aq*\(aq ¥ï¥¤¥ë¥É¥«¡¼¥É¤Ë¤Ï¥Þ¥Ã¥Á¤·¤Ê¤¤¡£
161 ¤Þ¤¿ "\fI[.\-0]\fP" ¤Î¤è¤¦¤ÊÎΰè»ØÄê¤Ë¤â¥Þ¥Ã¥Á¤·¤Ê¤¤¡£
162 Îΰè»ØÄê¤ÏÍۤˠ\(aq/\(aq Ê¸»ú¤ò´Þ¤à¤³¤È¤Ï¤Ç¤­¤Ê¤¤¡£¤³¤ì¤Ïʸˡ¥¨¥é¡¼¤È¤Ê¤ë¡£
163
164 .\"O If a filename starts with a \(aq.\(aq,
165 .\"O this character must be matched explicitly.
166 .\"O (Thus, \fIrm\ *\fP will not remove .profile, and \fItar\ c\ *\fP will not
167 .\"O archive all your files; \fItar\ c\ .\fP is better.)
168 \(aq.\(aq ¤Ç»Ï¤Þ¤ë¥Ñ¥¹Ì¾¤Ç¤Ï¡¢¤³¤Îʸ»ú¤ÏÍۤ˥ޥåÁ¤µ¤»¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
169 (¤Ä¤Þ¤ê \fIrm\ *\fP ¤Ï .profile ¤òºï½ü¤·¤Ê¤¤¡£¤Þ¤¿ \fItar\ c\ *\fP
170 ¤Ç¤Ï¤¹¤Ù¤Æ¤Î¥Õ¥¡¥¤¥ë¤Ï¥¢¡¼¥«¥¤¥Ö¤µ¤ì¤Ê¤¤¡£ \fItar\ c\ .\fP ¤ÎÊý¤¬Îɤ¤¡£)
171 .\"O .SS "Empty Lists"
172 .SS ¶õ¤Î¥ê¥¹¥È
173 .\"O The nice and simple rule given above: "expand a wildcard pattern
174 .\"O into the list of matching pathnames" was the original UNIX
175 .\"O definition.
176 .\"O It allowed one to have patterns that expand into
177 .\"O an empty list, as in
178 Àè¤ËÍ¿¤¨¤¿¡¢¤ï¤«¤ê¤ä¤¹¤¯´Êñ¤Ê¥ë¡¼¥ë¡¢
179 ¡Ö¥ï¥¤¥ë¥É¥«¡¼¥É¥Ñ¥¿¡¼¥ó¤ò¥Þ¥Ã¥Á¤·¤¿¥Ñ¥¹Ì¾¤Î¥ê¥¹¥È¤ËŸ³«¤¹¤ë¡×¤È¸À¤¦¤Î¤Ï¡¢
180 ¥ª¥ê¥¸¥Ê¥ë¤Î UNIX ¤Ë¤ª¤±¤ëÄêµÁ¤Ç¤¢¤Ã¤¿¡£
181 ¤³¤ì¤Ï¥Ñ¥¿¡¼¥ó¤¬¶õ¤Î¥ê¥¹¥È¤ËŸ³«¤µ¤ì¤ë¤³¤È¤âµö²Ä¤µ¤ì¤Æ¤¤¤¿¡£
182 Î㤨¤Ð
183 .br
184 .nf
185     xv \-wait 0 *.gif *.jpg
186 .fi
187 .\"O where perhaps no *.gif files are present (and this is not
188 .\"O an error).
189 ¤Ë¤ª¤¤¤Æ¡¢*.gif ¥Õ¥¡¥¤¥ë¤¬Á´¤¯¤Ê¤¤¾ì¹ç¤Ç¤â¡¢
190 ¤³¤ì¤Ï¶õ¤Î¥ê¥¹¥È¤ËŸ³«¤µ¤ì¤ë¤¿¤á¡¢¥¨¥é¡¼¤Ë¤Ê¤é¤Ê¤¤¡£
191 .\"O However, POSIX requires that a wildcard pattern is left
192 .\"O unchanged when it is syntactically incorrect, or the list of
193 .\"O matching pathnames is empty.
194 .\"O With
195 .\"O .I bash
196 .\"O one can force the classical behavior by setting
197 .\"O .IR allow_null_glob_expansion=true .
198 ¤·¤«¤· POSIX ¤Ç¤Ï¡¢Ê¸Ë¡Åª¤ËÀµ¤·¤¯¤Ê¤¤¥Ñ¥¿¡¼¥ó¤ä¡¢
199 ¥Þ¥Ã¥Á¤¬¤Ê¤«¤Ã¤¿¥Ñ¥¿¡¼¥ó¤Ï¡¢
200 ¤½¤Î¤Þ¤ÞÊѹ¹¤µ¤ì¤º¤Ë»Ä¤µ¤ì¤ë¤³¤È¤Ë¤Ê¤Ã¤Æ¤¤¤ë¡£
201 .I bash
202 ¤Ç¤Ï
203 .I allow_null_glob_expansion=true
204 ¤ò»ØÄꤹ¤ë¤³¤È¤Ç¡¢°ÊÁ°¤Î¿¶¤ëÉñ¤¤¤ËÀßÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤ë¡£
205
206 .\"O (Similar problems occur elsewhere.
207 .\"O E.g., where old scripts have
208 (ƱÍͤÎÌäÂê¤ÏÊ̤ΤȤ³¤í¤Ç¤âµ¯¤³¤Ã¤Æ¤¤¤ë¡£Î㤨¤Ð¡¢¸Å¤¤¥¹¥¯¥ê¥×¥È¤Ë¤ª¤±¤ë
209 .br
210 .nf
211     rm \`find . \-name "*~"\`
212 .fi
213 .\"O new scripts require
214 ¤Î¤è¤¦¤Êµ­½Ò¤Ï¡¢¿·¤·¤¤¥¹¥¯¥ê¥×¥È¤Ç¤Ï
215 .br
216 .nf
217     rm \-f nosuchfile \`find . \-name "*~"\`
218 .fi
219 .\"O to avoid error messages from
220 .\"O .I rm
221 .\"O called with an empty argument list.)
222 ¤Î¤è¤¦¤Ë¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£¤µ¤â¤Ê¤¤¤È
223 .I rm
224 ¤ò°ú¤­¿ô¥ê¥¹¥È¤Ê¤·¤Ç¸Æ¤Ó½Ð¤¹²ÄǽÀ­¤¬¤¢¤ê¡¢
225 ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤¬½Ð¤Æ¤·¤Þ¤¦¡£)
226 .\"O .SH NOTES
227 .SH Ãí°Õ
228 .\"O .SS Regular expressions
229 .SS Àµµ¬É½¸½
230 .\"O Note that wildcard patterns are not regular expressions,
231 .\"O although they are a bit similar.
232 .\"O First of all, they match
233 .\"O filenames, rather than text, and secondly, the conventions
234 .\"O are not the same: for example, in a regular expression \(aq*\(aq means zero or
235 .\"O more copies of the preceding thing.
236 ¥ï¥¤¥ë¥É¥«¡¼¥É¥Ñ¥¿¡¼¥ó¤ÏÀµµ¬É½¸½¤È¿¾¯»÷¤Æ¤¤¤ë¤¬¡¢¤·¤«¤·¤³¤Îξ¼Ô¤Ï°Û¤Ê¤ë¡£
237 ¤Þ¤ºÂè°ì¤Ë¡¢Á°¼Ô¤¬¥Õ¥¡¥¤¥ë̾¤Ë¥Þ¥Ã¥Á¤¹¤ë¤Î¤ËÂФ·¤Æ¡¢
238 ¸å¼Ô¤Ï¥Æ¥­¥¹¥È¤Ë¥Þ¥Ã¥Á¤¹¤ë¡£ÂèÆó¤Ë¡¢¥ë¡¼¥ë¤âƱ¤¸¤Ç¤Ï¤Ê¤¤¡£
239 Î㤨¤ÐÀµµ¬É½¸½¤Ë¤ª¤±¤ë \(aq*\(aq ¤Ï¡¢
240 Á°ÃÖ¤µ¤ì¤¿Ê¸»ú¤Î 0 °Ê¾å¤Î·«¤êÊÖ¤·¤òɽ¤¹¡£
241
242 .\"O Now that regular expressions have bracket expressions where
243 .\"O the negation is indicated by a \(aq^\(aq, POSIX has declared the
244 .\"O effect of a wildcard pattern "\fI[^...]\fP" to be undefined.
245 Àµµ¬É½¸½¤Ë¤â¥Ö¥é¥±¥Ã¥Èɽ¸½¤Ï¤¢¤ë¤¬¡¢ÈÝÄê¤Ï \(aq^\(aq ¤Ç¤Ê¤µ¤ì¤ë¡£
246 POSIX ¤Ç¤Ï¥ï¥¤¥ë¥É¥«¡¼¥É¥Ñ¥¿¡¼¥ó¤Ë¤ª¤±¤ë "\fI[^...]\fP" ¤ò̤ÄêµÁ¤Ç¤¢¤ë¤È¤·¤Æ¤¤¤ë¡£
247 .\"O .SS Character classes and Internationalization
248 .SS Ê¸»ú¥¯¥é¥¹¤È¹ñºÝ²½
249 .\"O Of course ranges were originally meant to be ASCII ranges,
250 .\"O so that "\fI[\ \-%]\fP" stands for "\fI[\ !"#$%]\fP" and "\fI[a\-z]\fP" stands
251 .\"O for "any lowercase letter".
252 .\"O Some UNIX implementations generalized this so that a range X\-Y
253 .\"O stands for the set of characters with code between the codes for
254 .\"O X and for Y.
255 .\"O However, this requires the user to know the
256 .\"O character coding in use on the local system, and moreover, is
257 .\"O not convenient if the collating sequence for the local alphabet
258 .\"O differs from the ordering of the character codes.
259 Îΰè»ØÄê¤Ï¡¢¤â¤È¤â¤È¤Ï¤â¤Á¤í¤ó ASCII ¤Ë¤ª¤±¤ë½ç½øʤӤò°ÕÌ£¤·¤Æ¤¤¤¿¡£
260 ¤·¤¿¤¬¤Ã¤Æ "\fI[\ \-%]\fP" ¤Ï "\fI[\ !"#$%]\fP" ¤Î°ÕÌ£¤Ç¤¢¤ê¡¢
261 "\fI[a\-z]\fP" ¤Ï¡Ö¤¹¤Ù¤Æ¤Î¾®Ê¸»ú¡×¤Î°ÕÌ£¤Ç¤¢¤Ã¤¿¡£
262 UNIX ¤Î¼ÂÁõ¤ÎÃæ¤Ë¤Ï¡¢¤³¤ì¤ò³ÈÄ¥¤·¤¿¤â¤Î¤¬Â¸ºß¤·¡¢
263 ¤½¤³¤Ç¤Ï X\-Y ¤È¤¤¤¦Îΰè»ØÄê¤Ï¡¢X ¤Î¥³¡¼¥É¤È
264 Y ¤Î¥³¡¼¥É¤Ë¶´¤Þ¤ì¤¿¥³¡¼¥É¤ò»ý¤Äʸ»ú¤¹¤Ù¤Æ¤òɽ¤¹¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤¿¡£
265 ¤·¤«¤·¡¢¤³¤ì¤Ë¤Ï¥æ¡¼¥¶¡¼¤¬¥í¡¼¥«¥ë¤Ê¥·¥¹¥Æ¥à¤Ë¤ª¤±¤ë
266 ʸ»ú¥³¡¼¥É¤òÃΤé¤Ê¤±¤ì¤Ð¤Ê¤é¤º¡¢
267 ¤µ¤é¤Ë¥í¡¼¥«¥ë¤Ê¥¢¥ë¥Õ¥¡¥Ù¥Ã¥È¤ËÂФ¹¤ë¾È¹ç½ç½ø
268 (collating sequence) ¤¬Ê¸»ú¥³¡¼¥É¤Î½ç½ø¤È°Û¤Ê¤Ã¤Æ¤¤¤ë¾ì¹ç¤Ë¤ÏÉÔÊؤǤ¢¤Ã¤¿¡£
269 (ÌõÃí: collating sequence ¤Ë´Ø¤·¤Æ¤Ï
270 .BR regex (7)
271 ¤ò»²¾È¤·¤Æ²¼¤µ¤¤¡£)
272 .\"O Therefore, POSIX extended the bracket notation greatly,
273 .\"O both for wildcard patterns and for regular expressions.
274 .\"O In the above we saw three types of items that can occur in a bracket
275 .\"O expression: namely (i) the negation, (ii) explicit single characters,
276 .\"O and (iii) ranges.
277 .\"O POSIX specifies ranges in an internationally
278 .\"O more useful way and adds three more types:
279 ¤·¤¿¤¬¤Ã¤Æ POSIX ¤Ç¤Ï¡¢¥ï¥¤¥ë¥É¥«¡¼¥É¥Ñ¥¿¡¼¥ó¤ÈÀµµ¬É½¸½¤ÎÁÐÊý¤Ë¤ª¤¤¤Æ¡¢
280 ¥Ö¥é¥±¥Ã¥Èɽµ­¤òÂçÉý¤Ë³ÈÄ¥¤·¤Æ¤¤¤ë¡£
281 ¤³¤ì¤Þ¤Ç²æ¡¹¤Ï¡¢¥Ö¥é¥±¥Ã¥Èɽµ­¤Ë¤Ï»°¤Ä¤ÎÍ×ÁǤ¬´Þ¤Þ¤ì¤¦¤ë¤³¤È¤ò¸«¤Æ¤­¤¿¡£
282 ¤¹¤Ê¤ï¤Á (i) ÈÝÄê¡¢(ii) Ã±°ì¤Îʸ»ú¡¢(iii) Îΰè»ØÄê¡¢¤Î»°¤Ä¤Ç¤¢¤ë¡£
283 POSIX ¤Ç¤Ï¡¢Îΰè»ØÄê¤ò¤è¤ê¹ñºÝ²½¤ËÊØÍø¤Ê¤è¤¦¤ËÄêµÁ¤·¤Æ¤ª¤ê¡¢
284 ¤Þ¤¿»°¤Ä¤Î¥¿¥¤¥×¤ò¥Ö¥é¥±¥Ã¥Èɽµ­¤ÎÍ×ÁǤȤ·¤ÆÄɲ䷤Ƥ¤¤ë¡£
285
286 .\"O (iii) Ranges X\-Y comprise all characters that fall between X
287 .\"O and Y (inclusive) in the currect collating sequence as defined
288 .\"O by the
289 .\"O .B LC_COLLATE
290 .\"O category in the current locale.
291 (iii) Îΰè»ØÄê X\-Y ¤Ï X ¤È Y ¤Ë¶´¤Þ¤ì¤¿ (ξü´Þ¤à) ¤¹¤Ù¤Æ¤Îʸ»ú¤ò°ÕÌ£¤¹¤ë¡£
292 ¤³¤Î¤È¤­¡¢¥«¥ì¥ó¥È¥í¥±¡¼¥ë (current locale) ¤Î
293 .B LC_COLLATE
294 ¥«¥Æ¥´¥ê¤ÇÄêµÁ¤µ¤ì¤Æ¤¤¤ë¾È¹ç½ç½ø¤¬ÍѤ¤¤é¤ì¤ë¡£
295
296 .\"O (iv) Named character classes, like
297 (iv) Ì¾Á°ÉÕ¤­Ê¸»ú¥¯¥é¥¹: °Ê²¼¤Î¤è¤¦¤Ê¤â¤Î¤Ç¤¢¤ë¡£
298 .nf
299
300 [:alnum:]  [:alpha:]  [:blank:]  [:cntrl:]
301 [:digit:]  [:graph:]  [:lower:]  [:print:]
302 [:punct:]  [:space:]  [:upper:]  [:xdigit:]
303
304 .fi
305 .\"O so that one can say "\fI[[:lower:]]\fP" instead of "\fI[a\-z]\fP", and have
306 .\"O things work in Denmark, too, where there are three letters past \(aqz\(aq
307 .\"O in the alphabet.
308 .\"O These character classes are defined by the
309 .\"O .B LC_CTYPE
310 .\"O category
311 .\"O in the current locale.
312 ¤³¤ì¤òÍѤ¤¤ì¤Ð "\fI[a\-z]\fP" ¤ÎÂå¤ï¤ê¤Ë "\fI[[:lower:]]\fP" ¤Î¤è¤¦¤Ê»ØÄ꤬¤Ç¤­¤ë¡£
313 ¤Þ¤¿¥Ç¥ó¥Þ¡¼¥¯¤Î¤è¤¦¤Ë¡¢¥¢¥ë¥Õ¥¡¥Ù¥Ã¥È¤Î \(aqz\(aq °Ê¹ß¤Ë
314 3 ¤Ä¤Îʸ»ú¤¬Â¸ºß¤¹¤ë¤è¤¦¤Ê¾ì¹ç¤Ç¤â¡¢Æ±¤¸¤è¤¦¤ÊÆ°ºî¤¬´üÂԤǤ­¤ë¡£
315 ¤³¤ì¤é¤Îʸ»ú¥¯¥é¥¹¤Ï¥«¥ì¥ó¥È¥í¥±¡¼¥ë¤Î
316 .B LC_CTYPE
317 ¥«¥Æ¥´¥ê¤ÇÄêµÁ¤µ¤ì¤Æ¤¤¤ë¡£
318
319 .\"O (v) Collating symbols, like "\fI[.ch.]\fP" or "\fI[.a-acute.]\fP",
320 .\"O where the string between "\fI[.\fP" and "\fI.]\fP" is a collating
321 .\"O element defined for the current locale.
322 .\"O Note that this may
323 .\"O be a multicharacter element.
324 (v) ¾È¹ç½ç½ø¤Ë¤ª¤±¤ë¥·¥ó¥Ü¥ë: "\fI[.ch.]\fP" ¤ä "\fI[.a-acute.]\fP" ¤Î¤è¤¦¤Ë "\fI[.\fP"
325 ¤È "\fI.]\fP" ¤Ç¶´¤Þ¤ì¤¿Ê¸»úÎó¤Ï¡¢¥«¥ì¥ó¥È¥í¥±¡¼¥ë¤ÇÄêµÁ¤µ¤ì¤¿¾È¹ç½ç½ø¤ÎÍ×ÁǤȤʤ롣
326 ¤¢¤ë°ì¤Ä¤ÎÍ×ÁǤ¬Ê£¿ô¤Îʸ»ú¤«¤é¤Ê¤ë¾ì¹ç¤â¤¢¤ê¤¦¤ë¤³¤È¤ËÃí°Õ¡£
327
328 .\"O (vi) Equivalence class expressions, like "\fI[=a=]\fP",
329 .\"O where the string between "\fI[=\fP" and "\fI=]\fP" is any collating
330 .\"O element from its equivalence class, as defined for the
331 .\"O current locale.
332 .\"O For example, "\fI[[=a=]]\fP" might be equivalent
333 .\"O .\" FIXME . the accented 'a' characters are not rendering properly
334 .\"O .\" mtk May 2007
335 .\"O to "\fI[aaaaa]\fP" (warning: Latin-1 here), that is,
336 .\"O to "\fI[a[.a-acute.][.a-grave.][.a-umlaut.][.a-circumflex.]]\fP".
337 (vi) Åù²Á¥¯¥é¥¹É½¸½ (equivalence class expressions): "\fI[=a=]\fP"
338 ¤Î¤è¤¦¤Ë "\fI[=\fP" ¤È "\fI=]\fP" ¤È¤Ç¶´¤Þ¤ì¤¿Ê¸»úÎó¤Ç¤¢¤ë¡£
339 ¤³¤ì¤ÏÅù²Á¥¯¥é¥¹¤Î¥á¥ó¥Ð¡¼¤Ç¤¢¤ë¾È¹ç½ç½ø¤ÎÍ×ÁǤ¹¤Ù¤Æ¤Ë¤Ê¤ë¡£
340 Åù²Á¥¯¥é¥¹¤Ï¥«¥ì¥ó¥È¥í¥±¡¼¥ë¤ÇÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤â¤Î¤Ë¤Ê¤ë¡£
341 Î㤨¤Ð¡¢"\fI[[=a=]]\fP" ¤Ï
342 "\fI[a[.a\-acute.][.a\-grave.][.a\-umlaut.][.a\-circumflex.]]\fP"
343 ¤ÈÅù²Á¤Ç¤¢¤ë
344 (Latin-1 É½µ­¤Ç¤Ï [a\e`{a}\e'{a}\e"{a}\e^{a}] ¤âƱ¤¸¡£
345 [ÌõÃí] ÆüËܸì¤Î roff ¥Ú¡¼¥¸¤Ç¤Ï latin1 ¥³¡¼¥É¤¬½Ð¤Ê¤¤¤Î¤Ç¡¢
346 ¤³¤³¤Ç¤Ï TeX É½µ­¤Çµ­ºÜ)¡£
347 .\"O .SH "SEE ALSO"
348 .SH ´ØÏ¢¹àÌÜ
349 .BR sh (1),
350 .BR fnmatch (3),
351 .BR glob (3),
352 .BR locale (7),
353 .BR regex (7)