3 .\"O Before a command is executed, its input and output
6 .\"O using a special notation interpreted by the shell.
7 .\"O Redirection may also be used to open and close files for the
8 .\"O current shell execution environment. The following redirection
9 .\"O operators may precede or appear anywhere within a
10 .\"O .I simple command
13 .\"O Redirections are processed in the order they appear, from
15 ¥·¥§¥ë¤¬²ò¼á¤¹¤ëÆÃÊ̤ʵˡ¤òÍѤ¤¤Æ¡¢¥³¥Þ¥ó¥É¤Î¼Â¹ÔÁ°¤ËÆþ½ÐÎϤò
17 ¤¹¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£¤Þ¤¿¡¢¥ê¥À¥¤¥ì¥¯¥È¤ò»È¤¦¤È¡¢¸½ºß¤Î¥·¥§¥ë¼Â¹Ô´Ä
18 ¶¤ËÂФ·¤Æ¥Õ¥¡¥¤¥ë¤ò¥ª¡¼¥×¥ó¤Þ¤¿¤Ï¥¯¥í¡¼¥º¤¹¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£°Ê²¼¤Ë
19 ¼¨¤¹¥ê¥À¥¤¥ì¥¯¥È±é»»»Ò¤Ï
21 ¤ÎÁ°¤äÅÓÃæ¤ËÃÖ¤¯¤³¤È¤¬¤Ç¤¤Þ¤¹¤·¡¢
23 ¤Î¸å¤ËÃÖ¤¯¤³¤È¤¬¤Ç¤¤Þ¤¹¡£¥ê¥À¥¤¥ì¥¯¥È¤Ïº¸¤«¤é±¦¤Ø¤È
24 ¸½¤ï¤ì¤¿½ç¤Ë½èÍý¤µ¤ì¤Þ¤¹¡£
26 .\"O In the following descriptions, if the file descriptor number is
27 .\"O omitted, and the first character of the redirection operator is
29 .\"O the redirection refers to the standard input (file descriptor
30 .\"O 0). If the first character of the redirection operator is
32 .\"O the redirection refers to the standard output (file descriptor
34 °Ê²¼¤ÎÀâÌÀ¤Ë¤ª¤¤¤Æ¤Ï¡¢¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼Èֹ椬¾Êά¤µ¤ì¡¢
35 ¤«¤Ä¥ê¥À¥¤¥ì¥¯¥È±é»»»Ò¤ÎºÇ½é¤Îʸ»ú¤¬
37 ¤Ê¤é¤Ð¡¢¥ê¥À¥¤¥ì¥¯¥È¤Ïɸ½àÆþÎÏ(¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼ 0)¤ò»²¾È¤·¤Þ¤¹¡£
38 ¥ê¥À¥¤¥ì¥¯¥È±é»»»Ò¤ÎºÇ½é¤Îʸ»ú¤¬
40 ¤Ê¤é¤Ð¡¢¥ê¥À¥¤¥ì¥¯¥È¤Ïɸ½à½ÐÎÏ(¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼ 1)¤ò»²¾È¤·¤Þ¤¹¡£
42 .\"O The word following the redirection operator in the following
43 .\"O descriptions, unless otherwise noted, is subjected to brace expansion,
44 .\"O tilde expansion, parameter expansion, command substitution, arithmetic
45 .\"O expansion, quote removal, pathname expansion, and word splitting.
46 .\"O If it expands to more than one word,
48 .\"O reports an error.
49 °Ê²¼¤ÎÀâÌÀ¤Ç¤Ï¡¢¥ê¥À¥¤¥ì¥¯¥È±é»»»Ò¤Î¼¡¤Îñ¸ì¤ËÂФ·¤Æ¤Ï¡¢ÆäËÀâÌÀ¤·
50 ¤Ê¤¤¸Â¤ê¡¢¥Ö¥ì¡¼¥¹Å¸³«¡¢¥Á¥ë¥ÀŸ³«¡¢¥Ñ¥é¥á¡¼¥¿Å¸³«¡¢¥³¥Þ¥ó¥ÉÃÖ´¹¡¢
51 »»½Ñ¼°Å¸³«¡¢¥¯¥©¡¼¥Èºï½ü¡¢¥Ñ¥¹Ì¾Å¸³«¡¢Ã±¸ìʬ³ä¤¬¹Ô¤ï¤ì¤Þ¤¹¡£
52 ¤¢¤ëñ¸ì¤¬Ê£¿ô¤Îñ¸ì¤ËŸ³«¤µ¤ì¤¿¾ì¹ç¤Ï¥¨¥é¡¼¤Ë¤Ê¤ê¤Þ¤¹¡£
54 .\"O Note that the order of redirections is significant. For example,
56 ¥ê¥À¥¤¥ì¥¯¥È¤Î½çÈ֤ˤϰÕÌ£¤¬¤¢¤ëÅÀ¤ËÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£
60 ls \fB>\fP dirlist 2\fB>&\fP1
63 .\"O directs both standard output and standard error to the file
65 .\"O while the command
66 ¤Ïɸ½à½ÐÎϤÈɸ½à¥¨¥é¡¼½ÐÎϤòξÊý¤È¤â¥Õ¥¡¥¤¥ë
68 ¤Ë½ñ¤¹þ¤ß¤Þ¤¹¤¬¡¢¼¡¤Î¥³¥Þ¥ó¥É
71 ls 2\fB>&\fP1 \fB>\fP dirlist
74 .\"O directs only the standard output to file
76 .\"O because the standard error was duplicated as standard output
77 .\"O before the standard output was redirected to
79 ¤Ç¤Ïɸ½à½ÐÎϤÀ¤±¤¬¥Õ¥¡¥¤¥ë
81 ¤Ë½ñ¤¹þ¤Þ¤ì¤Þ¤¹¡£¤Ê¤¼¤Ê¤é¸å¼Ô¤Î¾ì¹ç¤Ë¤Ï¡¢É¸½à¥¨¥é¡¼½ÐÎϤÏ
83 ¤Ë¥ê¥À¥¤¥ì¥¯¥È¤µ¤ì¤ëÁ°¤Îɸ½à½ÐÎϤÎÊ£À½¤È¤Ê¤ë¤«¤é¤Ç¤¹¡£
86 .\"O \fBBash\fP handles several filenames specially when they are used in
87 .\"O redirections, as described in the following table:
88 \fBbash\fP ¤Ï¥ê¥À¥¤¥ì¥¯¥È¤Ë»ÈÍѤ·¤¿¾ì¹ç¤Ë¡¢°Ê²¼¤Îɽ¤Ë¤¢¤ë¤è¤¦¤Ê
89 ¤¤¤¯¤Ä¤«¤ÎÆÃÊ̤ʥե¡¥¤¥ë̾»ØÄê¤ò°·¤¦¤³¤È¤¬¤Ç¤¤Þ¤¹¡£
95 .\"O If \fIfd\fP is a valid integer, file descriptor \fIfd\fP is duplicated.
96 \fIfd\fP ¤¬Í¸ú¤ÊÀ°¿ô¤Ê¤é¤Ð¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼ \fIfd\fP ¤¬Ê£À½¤µ¤ì¤Þ¤¹¡£
99 .\"O File descriptor 0 is duplicated.
100 ¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼ 0 ¤¬Ê£À½¤µ¤ì¤Þ¤¹¡£
103 .\"O File descriptor 1 is duplicated.
104 ¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼ 1 ¤¬Ê£À½¤µ¤ì¤Þ¤¹¡£
107 .\"O File descriptor 2 is duplicated.
108 ¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼ 2 ¤¬Ê£À½¤µ¤ì¤Þ¤¹¡£
110 .B /dev/tcp/\fIhost\fP/\fIport\fP
111 .\"O If \fIhost\fP is a valid hostname or Internet address, and \fIport\fP
112 .\"O is an integer port number, \fBbash\fP attempts to open a TCP connection
113 .\"O to the corresponding socket.
114 \fIhost\fP ¤¬Í¸ú¤Ê¥Û¥¹¥È̾¤Þ¤¿¤Ï¥¤¥ó¥¿¡¼¥Í¥Ã¥È¥¢¥É¥ì¥¹¤Ç
115 \fIport\fP ¤¬À°¿ô¤Î¥Ý¡¼¥ÈÈÖ¹æ¤Ê¤é¤Ð¡¢\fBbash\fP ¤ÏÂбþ¤¹¤ë¥½¥±¥Ã¥È¤Ë
116 ÂФ·¤Æ TCP Àܳ¤Î¥ª¡¼¥×¥ó¤ò»î¤ß¤Þ¤¹¡£
118 .B /dev/udp/\fIhost\fP/\fIport\fP
119 .\"O If \fIhost\fP is a valid hostname or Internet address, and \fIport\fP
120 .\"O is an integer port number, \fBbash\fP attempts to open a UDP connection
121 .\"O to the corresponding socket.
122 \fIhost\fP ¤¬Í¸ú¤Ê¥Û¥¹¥È̾¤Þ¤¿¤Ï¥¤¥ó¥¿¡¼¥Í¥Ã¥È¥¢¥É¥ì¥¹¤Ç
123 \fIport\fP ¤¬À°¿ô¤Î¥Ý¡¼¥ÈÈÖ¹æ¤Ê¤é¤Ð¡¢\fBbash\fP ¤ÏÂбþ¤¹¤ë¥½¥±¥Ã¥È¤Ë
124 ÂФ·¤Æ UDP Àܳ¤Î¥ª¡¼¥×¥ó¤ò»î¤ß¤Þ¤¹¡£
125 \" ÌõÃí UDP connection ¤È¤¤¤¦¤Î¤Ï¥Ê¥ó¥»¥ó¥¹?!?
129 .\"O A failure to open or create a file causes the redirection to fail.
130 ¥Õ¥¡¥¤¥ë¤Î¥ª¡¼¥×¥ó¤äºîÀ®¤Ë¼ºÇÔ¤¹¤ë¤È¡¢¥ê¥À¥¤¥ì¥¯¥È¤â¼ºÇÔ¤·¤Þ¤¹¡£
131 .\"O .SS Redirecting Input
132 .SS ÆþÎϤΥê¥À¥¤¥ì¥¯¥È
134 .\"O Redirection of input causes the file whose name results from
135 .\"O the expansion of
137 .\"O to be opened for reading on file descriptor
139 .\"O or the standard input (file descriptor 0) if
141 .\"O is not specified.
142 ÆþÎϤò¥ê¥À¥¤¥ì¥¯¥È¤¹¤ë¤È¡¢
144 ¤ÎŸ³«¤ÇÆÀ¤¿Ì¾Á°¤ò»ý¤Ä¥Õ¥¡¥¤¥ë¤¬¥ª¡¼¥×¥ó¤µ¤ì¡¢¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼
146 ¤ÇÆɤ߹þ¤á¤ë¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£
148 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢Æɤ߹þ¤ß¤Ïɸ½àÆþÎÏ(¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼ 0)¤Ç
151 .\"O The general format for redirecting input is:
152 ÆþÎϤΥê¥À¥¤¥ì¥¯¥È¤Ï¡¢°ìÈÌŪ¤Ë¤Ï°Ê²¼¤Î·Á¼°¤Ç¤¹:
155 [\fIn\fP]\fB<\fP\fIword\fP
157 .\"O .SS Redirecting Output
158 .SS ½ÐÎϤΥê¥À¥¤¥ì¥¯¥È
160 .\"O Redirection of output causes the file whose name results from
161 .\"O the expansion of
163 .\"O to be opened for writing on file descriptor
165 .\"O or the standard output (file descriptor 1) if
167 .\"O is not specified. If the file does not exist it is created;
168 .\"O if it does exist it is truncated to zero size.
169 ½ÐÎϤò¥ê¥À¥¤¥ì¥¯¥È¤¹¤ë¤È¡¢
171 ¤ÎŸ³«¤ÇÆÀ¤¿Ì¾Á°¤ò»ý¤Ä¥Õ¥¡¥¤¥ë¤¬¥ª¡¼¥×¥ó¤µ¤ì¡¢¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼
173 ¤Ç½ñ¤¹þ¤á¤ë¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£
175 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢Æɤ߹þ¤ß¤Ïɸ½à½ÐÎÏ(¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼ 1)¤Ç
177 ¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤·¤Ê¤«¤Ã¤¿¾ì¹ç¤ÏºîÀ®¤µ¤ì¤Þ¤¹¡£¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤·¤¿¾ì¹ç¤Ï
178 ¥µ¥¤¥º 0 ¤ËÀÚ¤êµÍ¤á¤é¤ì¤Þ¤¹¡£
180 .\"O The general format for redirecting output is:
181 ½ÐÎϤΥê¥À¥¤¥ì¥¯¥È¤Ï¡¢°ìÈÌŪ¤Ë¤Ï°Ê²¼¤Î·Á¼°¤Ç¤¹:
184 [\fIn\fP]\fB>\fP\fIword\fP
187 .\"O If the redirection operator is
193 .\"O builtin has been enabled, the redirection will fail if the file
194 .\"O whose name results from the expansion of \fIword\fP exists and is
200 ¥ª¥×¥·¥ç¥ó¤¬ÁȤ߹þ¤ß¥³¥Þ¥ó¥É
202 ¤ËÂФ·¤ÆÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢\fIword\fP ¤ÎŸ³«¤ÇÆÀ¤¿¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤·¡¢
203 ¤«¤Ä¤½¤ì¤¬Ä̾ï¥Õ¥¡¥¤¥ë¤Ê¤é¤Ð¡¢¥ê¥À¥¤¥ì¥¯¥È¤Ï¼ºÇÔ¤·¤Þ¤¹¡£
204 .\"O If the redirection operator is
206 .\"O or the redirection operator is
212 .\"O builtin command is not enabled, the redirection is attempted even
213 .\"O if the file named by \fIword\fP exists.
223 ¥ª¥×¥·¥ç¥ó¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢\fIword\fP ¤È¤¤¤¦Ì¾Á°¤Î¥Õ¥¡¥¤¥ë¤¬
224 ¸ºß¤·¤Æ¤¤¤Æ¤â¥ê¥À¥¤¥ì¥¯¥È¤¬»î¤ß¤é¤ì¤Þ¤¹¡£
225 .\"O .SS Appending Redirected Output
226 .SS ¥ê¥À¥¤¥ì¥¯¥È¤Ë¤è¤ëÄɲýÐÎÏ
228 .\"O Redirection of output in this fashion
229 .\"O causes the file whose name results from
230 .\"O the expansion of
232 .\"O to be opened for appending on file descriptor
234 .\"O or the standard output (file descriptor 1) if
236 .\"O is not specified. If the file does not exist it is created.
237 ¤³¤Î·Á¼°¤ò»È¤Ã¤Æ½ÐÎϤΥê¥À¥¤¥ì¥¯¥È¤ò¹Ô¤¦¤È¡¢
239 ¤òŸ³«¤·¤¿·ë²Ì¤Î̾Á°¤ò»ý¤Ä¥Õ¥¡¥¤¥ë¤¬¥ª¡¼¥×¥ó¤µ¤ì¡¢¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼
241 ¤ËÂФ¹¤ë½ÐÎϤ¬¤³¤Î¥Õ¥¡¥¤¥ë¤ËÄɲ䵤ì¤ë¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£
243 ¤ò»ØÄꤷ¤Ê¤±¤ì¤Ð¡¢É¸½à½ÐÎÏ(¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼ 1)¤ÇÄɲ䵤ì¤Þ¤¹¡£
244 ¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤·¤Ê¤±¤ì¤Ð¡¢¿·¤·¤¯ºî¤é¤ì¤Þ¤¹¡£
246 .\"O The general format for appending output is:
247 ÄɲýÐÎϤϰìÈÌŪ¤Ë¤Ï°Ê²¼¤Î·Á¼°¤Ç¤¹:
250 [\fIn\fP]\fB>>\fP\fIword\fP
253 .\"O .SS Redirecting Standard Output and Standard Error
254 .SS ɸ½à½ÐÎϤÈɸ½à¥¨¥é¡¼½ÐÎϤΥê¥À¥¤¥ì¥¯¥È
258 .\"O standard output (file descriptor 1) and
259 .\"O the standard error output (file descriptor 2)
260 .\"O to be redirected to the file whose name is the
263 .\"O with this construct.
265 ¤Ç¤Ï¤³¤Î¹½Â¤¤ò»È¤Ã¤Æ¡¢É¸½à½ÐÎÏ(¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼ 1)¤Èɸ½à¥¨¥é¡¼½ÐÎÏ
266 (¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼ 2)¤ÎξÊý¤ò¡¢
268 ¤òŸ³«¤·¤ÆÆÀ¤¿Ì¾Á°¤ò»ý¤Ä¥Õ¥¡¥¤¥ë¤Ë¥ê¥À¥¤¥ì¥¯¥È¤µ¤»¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£
270 .\"O There are two formats for redirecting standard output and
272 ɸ½à½ÐÎϤÈɸ½à¥¨¥é¡¼½ÐÎϤËÂФ¹¤ë·Á¼°¤Ï 2 ¤Ä¤¢¤ê¤Þ¤¹:
283 .\"O Of the two forms, the first is preferred.
284 .\"O This is semantically equivalent to
285 ξ¼Ô¤Î¤¦¤Á˾¤Þ¤·¤¤¤Î¤ÏÁ°¼Ô¤ÎÊý¤Ç¤¹¡£¤³¤ì¤Ï¼¡¤Î¤â¤Î¤ÈƱ¤¸°ÕÌ£¤Ç¤¹:
288 \fB>\fP\fIword\fP 2\fB>&\fP1
290 .\"O .SS Here Documents
291 .SS ¥Ò¥¢¥É¥¥å¥á¥ó¥È(Here Documents)
293 .\"O This type of redirection instructs the shell to read input from the
294 .\"O current source until a line containing only
296 .\"O (with no trailing blanks)
298 .\"O the lines read up to that point are then used as the standard
299 .\"O input for a command.
300 ¤³¤Î¥¿¥¤¥×¤Î¥ê¥À¥¤¥ì¥¯¥È¤Ï¸½ºß¤Î¥½¡¼¥¹¤«¤éÆþÎϤòÆɤ߹þ¤à¤è¤¦¤Ë
301 ¥·¥§¥ë¤Ë»Ø¼¨¤·¤Þ¤¹¡£¤³¤ÎÆɤ߹þ¤ß¤Ï
303 ¤òñÆȤǴޤà¹Ô(ËöÈø¤Ë¥Ö¥é¥ó¥¯Ê¸»ú¤¬¤¢¤Ã¤Æ¤Ï¤Ê¤ê¤Þ¤»¤ó)¤¬¸½¤ï¤ì¤ë¤Þ¤Ç
304 ¹Ô¤ï¤ì¤Þ¤¹¡£¤½¤ÎÉôʬ¤Þ¤Ç¤ËÆɤ߹þ¤ó¤À¹Ô¤ÏÁ´¤Æ¤¢¤ë¥³¥Þ¥ó¥É¤ËÂФ¹¤ë
305 ɸ½àÆþÎϤȤ·¤Æ»È¤ï¤ì¤Þ¤¹¡£
307 .\"O The format of here-documents is as follows:
308 ¥Ò¥¢¥É¥¥å¥á¥ó¥È¤Î·Á¼°¤ò°Ê²¼¤Ë¼¨¤·¤Þ¤¹:
312 \fB<<\fP[\fB\-\fP]\fIword\fP
318 .\"O No parameter expansion, command substitution, arithmetic expansion,
319 .\"O or pathname expansion is performed on
322 ¤ËÂФ¹¤ë¥Ñ¥é¥á¡¼¥¿Å¸³«¡¢¥³¥Þ¥ó¥ÉÃÖ´¹¡¢»»½Ñ¼°Å¸³«¡¢¥Ñ¥¹Ì¾Å¸³«¤Ï
324 .\"O If any characters in
328 .\"O is the result of quote removal on
330 .\"O and the lines in the here-document are not expanded.
332 ¤¬°ìÉô¤Ç¤â¥¯¥©¡¼¥È¤µ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢
336 ¤Î¥¯¥©¡¼¥È¤òºï½ü¤·¤¿·ë²Ì¤ò»ÈÍѤ·¡¢
337 ¥Ò¥¢¥É¥¥å¥á¥ó¥È¤Ë´Þ¤Þ¤ì¤ë¹Ô¤ÎŸ³«¤Ï¹Ô¤ï¤ì¤Þ¤»¤ó¡£
338 .\"O If \fIword\fP is unquoted,
339 .\"O all lines of the here-document are subjected to parameter expansion,
340 .\"O command substitution, and arithmetic expansion. In the latter
341 .\"O case, the character sequence
345 .\"O must be used to quote the characters
350 \fIword\fP ¤¬¥¯¥©¡¼¥È¤µ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢¥Ò¥¢¥É¥¥å¥á¥ó¥ÈÃæ¤ÎÁ´¤Æ¤Î¹Ô¤Ë
351 ÂФ·¤Æ¥Ñ¥é¥á¡¼¥¿Å¸³«¡¢¥³¥Þ¥ó¥ÉÃÖ´¹¡¢»»½Ñ¼°Å¸³«¤¬¹Ô¤ï¤ì¤Þ¤¹¡£
354 ¤ÎÁȤ߹ç¤ï¤»¤Ï̵»ë¤µ¤ì¡¢
358 ¤ò¥¯¥©¡¼¥È¤¹¤ë¤¿¤á¤Ë¤Ï
360 ¤ò»È¤ï¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£
362 .\"O If the redirection operator is
364 .\"O then all leading tab characters are stripped from input lines and the
369 ¤Ê¤é¤Ð¡¢¹ÔƬ¤Ë¤¢¤ë¥¿¥Öʸ»ú¤ÏÁ´¤ÆÆþÎϹԤª¤è¤Ó
371 ¤ò´Þ¤à¹Ô¤«¤é¼è¤ê½ü¤«¤ì¤Þ¤¹¡£
373 .\"O here-documents within shell scripts to be indented in a
374 .\"O natural fashion.
375 ¤³¤ì¤Ë¤è¤ê¡¢¥·¥§¥ë¥¹¥¯¥ê¥×¥ÈÃæ¤Î¥Ò¥¢¥É¥¥å¥á¥ó¥È¤ò¼«Á³¤Ê·Á¤Ç¥¤¥ó¥Ç¥ó¥È
376 ¤µ¤»¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£
377 .\"O .SS "Duplicating File Descriptors"
378 .SS ¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼¤ÎÊ£À½
380 .\"O The redirection operator
384 [\fIn\fP]\fB<&\fP\fIword\fP
387 .\"O is used to duplicate input file descriptors.
388 ¤ò»È¤Ã¤ÆÆþÎÏ¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼¤òÊ£À½¤Ç¤¤Þ¤¹¡£
391 .\"O expands to one or more digits, the file descriptor denoted by
393 .\"O is made to be a copy of that file descriptor.
395 ¤¬ 1 ·å°Ê¾å¤Î¿ôÃͤËŸ³«¤µ¤ì¤¿¾ì¹ç¡¢
397 ¤Ç¼¨¤µ¤ì¤ë¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼¤¬À¸À®¤µ¤ì¡¢
398 ¤½¤Î¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼¤Î¥³¥Ô¡¼¤È¤Ê¤ê¤Þ¤¹¡£
399 .\"O If the digits in
401 .\"O do not specify a file descriptor open for input, a redirection error occurs.
403 ¤Ë´Þ¤Þ¤ì¤ë¿ôÃͤ¬ÆþÎϤΤ¿¤á¤Ë¥ª¡¼¥×¥ó¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼¤ò
404 »Ø¤·¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢¥ê¥À¥¤¥ì¥¯¥È¡¦¥¨¥é¡¼¤¬µ¯¤¤Þ¤¹¡£
413 .\"O is not specified, the standard input (file descriptor 0) is used.
417 ¤È¤Ê¤Ã¤¿¾ì¹ç¡¢¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼
421 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢É¸½àÆþÎÏ(¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼ 0)¤¬»È¤ï¤ì¤Þ¤¹¡£
427 [\fIn\fP]\fB>&\fP\fIword\fP
430 .\"O is used similarly to duplicate output file descriptors. If
432 .\"O is not specified, the standard output (file descriptor 1) is used.
433 ¤ò»È¤Ã¤Æ½ÐÎÏ¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼¤òÊ£À½¤¹¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£
435 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ï¡¢É¸½à½ÐÎÏ(¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼ 1)¤¬»È¤ï¤ì¤Þ¤¹¡£
436 .\"O If the digits in
438 .\"O do not specify a file descriptor open for output, a redirection error occurs.
439 .\"O As a special case, if \fIn\fP is omitted, and \fIword\fP does not
440 .\"O expand to one or more digits, the standard output and standard
441 .\"O error are redirected as described previously.
443 ¤Ë´Þ¤Þ¤ì¤ë¿ôÃͤ¬¡¢½ÐÎϤΤ¿¤á¤Ë¥ª¡¼¥×¥ó¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼¤ò
444 »Ø¤·¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢¥ê¥À¥¤¥ì¥¯¥È¡¦¥¨¥é¡¼¤¬µ¯¤¤Þ¤¹¡£ÆÃÊ̤ʾì¹ç¤Ç¤¹¤¬¡¢
445 \fIn\fP ¤¬¾Êά¤µ¤ì¡¢¤«¤Ä \fIword\fP ¤¬ 1 ·å°Ê¾å¤Î¿ô»ú¤Ë¤ÏŸ³«¤µ¤ì¤Ê¤«¤Ã
446 ¤¿¾ì¹ç¡¢Á°¤ËÀâÌÀ¤·¤¿¤è¤¦¤Ëɸ½à½ÐÎϤÈɸ½à¥¨¥é¡¼½ÐÎϤ¬¥ê¥À¥¤¥ì¥¯¥È¤µ¤ì¤Þ¤¹¡£
447 .\"O .SS "Opening File Descriptors for Reading and Writing"
448 .SS Æɤ߽ñ¤¤Î¤¿¤á¤Î¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼¤Î¥ª¡¼¥×¥ó
450 .\"O The redirection operator
454 [\fIn\fP]\fB<>\fP\fIword\fP
457 .\"O causes the file whose name is the expansion of
459 .\"O to be opened for both reading and writing on file descriptor
461 .\"O or on file descriptor 0 if
463 .\"O is not specified. If the file does not exist, it is created.
466 ¤òŸ³«¤·¤¿·ë²Ì¤Î̾Á°¤ò»ý¤Ä¥Õ¥¡¥¤¥ë¤¬¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼
468 ¤Ç¤ÎÆɤ߽ñ¤¤Î¤¿¤á¤Ë¥ª¡¼¥×¥ó¤µ¤ì¤Þ¤¹¡£
470 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¼ 0 ¤ÇÆɤ߽ñ¤¤¬¹Ô¤ï¤ì¤Þ¤¹¡£
471 ¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤·¤Ê¤±¤ì¤Ð¡¢¿·¤·¤¯À¸À®¤µ¤ì¤Þ¤¹¡£
474 .\"O \fIAliases\fP allow a string to be substituted for a word when it is used
475 .\"O as the first word of a simple command.
476 \fI¥¨¥¤¥ê¥¢¥¹(alias)\fP ¤ò»È¤¦¤È¡¢¤¢¤ëñ¸ì¤¬Ã±½ã¤Ê¥³¥Þ¥ó¥É¤ÎÀèƬ¤Î
477 ñ¸ì¤È¤·¤Æ»È¤ï¤ì¤¿¾ì¹ç¤Ë¡¢¤³¤Îʸ»úÎó¤òÊ̤Îñ¸ì¤ËÃÖ´¹¤¹¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£
478 .\"O The shell maintains a list of aliases that may be set and unset with the
482 .\"O builtin commands (see
484 .\"O .B SHELL BUILTIN COMMANDS
486 ¥·¥§¥ë¤Ï¥¨¥¤¥ê¥¢¥¹¤Î¥ê¥¹¥È¤ò´ÉÍý¤·¤Æ¤¤¤Þ¤¹¡£
487 ¤³¤Î¥ê¥¹¥È¤ÏÁȤ߹þ¤ß¥³¥Þ¥ó¥É¤Î
491 ¤ò»È¤Ã¤ÆÀßÄꤪ¤è¤ÓÀßÄê¤Î¼è¤ê¾Ã¤·¤ò¹Ô¤¦¤³¤È¤¬¤Ç¤¤Þ¤¹(¸å½Ò¤Î
493 .B ¥·¥§¥ë¤ÎÁȤ߹þ¤ß¥³¥Þ¥ó¥É
495 .\"O The first word of each command, if unquoted,
496 .\"O is checked to see if it has an
497 .\"O alias. If so, that word is replaced by the text of the alias.
498 ³Æ¥³¥Þ¥ó¥É¤ÎºÇ½é¤Îñ¸ì¤¬¥¯¥©¡¼¥È¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¡¢
499 ¥¨¥¤¥ê¥¢¥¹¤«¤É¤¦¤«³Îǧ¤µ¤ì¡¢¥¨¥¤¥ê¥¢¥¹¤Ê¤é¤Ð¤½¤Îñ¸ì¤Ï
500 ¤½¤Î¥¨¥¤¥ê¥¢¥¹¤Î¥Æ¥¥È¥¹¤ÈÃÖ´¹¤µ¤ì¤Þ¤¹¡£
501 .\"O The alias name and the replacement text may contain any valid
502 .\"O shell input, including the
503 .\"O .I metacharacters
504 .\"O listed above, with the exception that the alias name may not
505 .\"O contain \fI=\fP. The first word of the replacement text is tested
506 .\"O for aliases, but a word that is identical to an alias being expanded
507 .\"O is not expanded a second time. This means that one may alias
511 .\"O for instance, and
513 .\"O does not try to recursively expand the replacement text.
514 ¥¨¥¤¥ê¥¢¥¹Ì¾¤ÈÃÖ´¹¤µ¤ì¤ë¥Æ¥¥¹¥È¤Ë¤Ï¡¢¥·¥§¥ë¤ÎÆþÎϤȤ·¤Æ͸ú¤Ê¤â¤Î¤Ï²¿
515 ¤Ç¤â´Þ¤á¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£¤³¤ì¤Ë¤ÏÀè¤Ëµó¤²¤¿
517 ¤â´Þ¤Þ¤ì¤Þ¤¹¤¬¡¢¥¨¥¤¥ê¥¢¥¹Ì¾¤Ë¤Ï \fI=\fP ¤ò´Þ¤á¤ë¤³¤È¤¬¤Ç¤¤Ê¤¤¤È¤¤¤¦
518 Îã³°¤¬¤¢¤ê¤Þ¤¹¡£ÃÖ´¹¤µ¤ì¤ë¥Æ¥¥¹¥È¤ÎºÇ½é¤Îñ¸ì¤Ï¥¨¥¤¥ê¥¢¥¹¤ò
519 ɾ²Á¤µ¤ì¤Þ¤¹¤¬¡¢ºÇ½é¤Îñ¸ì¤¬Å¸³«¤µ¤ì¤ë¥¨¥¤¥ê¥¢¥¹¤ÈƱ¤¸¾ì¹ç¤Ë¤Ï¡¢
520 Ÿ³«¤Ï 1ÅÙ¤·¤«¹Ô¤ï¤ì¤Þ¤»¤ó¡£¤Ä¤Þ¤ê¡¢
524 ¤Î¥¨¥¤¥ê¥¢¥¹¤È¤Ê¤Ã¤Æ¤¤¤ë¤è¤¦¤Ê¾ì¹ç¤Ë¤Ï¡¢
526 ¤ÏÃÖ´¹¤µ¤ì¤ëʸ»úÎó¤òºÆµ¢Åª¤ËŸ³«¤¹¤ë¤³¤È¤Ï¤¢¤ê¤Þ¤»¤ó¡£
527 .\"O If the last character of the alias value is a
529 .\"O then the next command
530 .\"O word following the alias is also checked for alias expansion.
531 ¥¨¥¤¥ê¥¢¥¹¤ÎÃͤκǸå¤Îʸ»ú¤¬
533 ¤Î¾ì¹ç¡¢¥¨¥¤¥ê¥¢¥¹¤Ë³¤¯¼¡¤Î¥³¥Þ¥ó¥É¤Îñ¸ì¤ËÂФ·¤Æ¤â
534 ¥¨¥¤¥ê¥¢¥¹Å¸³«¤¬»î¤ß¤é¤ì¤Þ¤¹¡£
536 .\"O Aliases are created and listed with the
538 .\"O command, and removed with the
543 ¥³¥Þ¥ó¥É¤ÇºîÀ®¤È¥ê¥¹¥Èɽ¼¨¤ò¹Ô¤¤¡¢
545 ¥³¥Þ¥ó¥É¤Çºï½ü¤·¤Þ¤¹¡£
547 .\"O There is no mechanism for using arguments in the replacement text.
548 .\"O If arguments are needed, a shell function should be used (see
552 ÃÖ´¹¤µ¤ì¤ë¥Æ¥¥¹¥È¤Ë°ú¤¿ô¤òÆþ¤ì¤ë»ÅÁȤߤϤ¢¤ê¤Þ¤»¤ó¡£°ú¤¿ô¤¬É¬Íפʤé
553 ¤Ð¡¢¥·¥§¥ë´Ø¿ô¤ò»È¤ï¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó(¸å½Ò¤Î
558 .\"O Aliases are not expanded when the shell is not interactive, unless
560 .\"O .B expand_aliases
561 .\"O shell option is set using
563 .\"O (see the description of
567 .\"O \fBSHELL BUILTIN COMMANDS\fP
569 ¥·¥§¥ë¤¬ÂÐÏÃŪ¤Ç¤Ê¤¤»þ¤Ë¤Ï¡¢
573 ¥ª¥×¥·¥ç¥ó¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¸Â¤ê¥¨¥¤¥ê¥¢¥¹¤ÎŸ³«¤Ï¹Ô¤ï¤ì¤Þ¤»¤ó(¸å½Ò¤Î
575 \fB¥·¥§¥ë¤ÎÁȤ߹þ¤ß¥³¥Þ¥ó¥É\fP
578 ¤ÎÀâÌÀ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤)¡£
580 .\"O The rules concerning the definition and use of aliases are
581 .\"O somewhat confusing.
582 ¥¨¥¤¥ê¥¢¥¹¤ÎÄêµÁ¤äÍøÍѤ˴ط¸¤¹¤ëµ¬Â§¤Ë¤Ï¡¢Ê¶¤é¤ï¤·¤¤ÅÀ¤¬¤¢¤ê¤Þ¤¹¡£
584 .\"O always reads at least one complete line
585 .\"O of input before executing any
586 .\"O of the commands on that line. Aliases are expanded when a
587 .\"O command is read, not when it is executed. Therefore, an
588 .\"O alias definition appearing on the same line as another
589 .\"O command does not take effect until the next line of input is read.
591 ¤Ï¡¢¤¢¤ë¹Ô¤Ë½ñ¤«¤ì¤Æ¤¤¤ë¥³¥Þ¥ó¥É¤ò¼Â¹Ô¤¹¤ëÁ°¤Ëɬ¤º¡¢¾¯¤Ê¤¯¤È¤â 1 ²ó¤Ï
592 ¹ÔÁ´ÂΤòÆɤ߹þ¤ß¤Þ¤¹¡£¥¨¥¤¥ê¥¢¥¹¤¬Å¸³«¤µ¤ì¤ë¤Î¤Ï¥³¥Þ¥ó¥É¤ò
593 Æɤ߹þ¤ó¤À»þ¤Ç¤¢¤ê¡¢¼Â¹Ô¤¹¤ë»þ¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£
594 ¤·¤¿¤¬¤Ã¤Æ¡¢Ê̤Υ³¥Þ¥ó¥É¤ÈƱ¤¸¹Ô¤Ç¥¨¥¤¥ê¥¢¥¹ÄêµÁ¤ò¹Ô¤Ã¤¿¾ì¹ç¤Ë¤Ï¡¢
595 ¼¡¤ÎÆþÎϹԤ¬Æɤ߹þ¤Þ¤ì¤ë¤Þ¤Ç¤Ï¥¨¥¤¥ê¥¢¥¹¤Î¸ú²Ì¤Ï¸½¤ï¤ì¤Þ¤»¤ó¡£
596 .\"O The commands following the alias definition
597 .\"O on that line are not affected by the new alias.
598 Ʊ¤¸¹Ô¤Ë¤¢¤ë¥¨¥¤¥ê¥¢¥¹ÄêµÁ¤Î¸å¤Î¥³¥Þ¥ó¥É¤Ï¡¢¿·¤·¤¤¥¨¥¤¥ê¥¢¥¹¤Î±Æ¶Á¤ò
600 .\"O This behavior is also an issue when functions are executed.
601 ¤³¤ÎÆ°ºî¤Ï´Ø¿ô¤ò¼Â¹Ô¤¹¤ë¾ì¹ç¤Ë¤âÌäÂê¤Ë¤Ê¤ê¤Þ¤¹¡£
602 .\"O Aliases are expanded when a function definition is read,
603 .\"O not when the function is executed, because a function definition
604 .\"O is itself a compound command. As a consequence, aliases
605 .\"O defined in a function are not available until after that
606 .\"O function is executed. To be safe, always put
607 .\"O alias definitions on a separate line, and do not use
609 .\"O in compound commands.
610 ¥¨¥¤¥ê¥¢¥¹¤¬Å¸³«¤µ¤ì¤ë¤Î¤Ï´Ø¿ôÄêµÁ¤¬Æɤ߹þ¤Þ¤ì¤ë»þ¤Ç¤¢¤ê¡¢
611 ´Ø¿ô¤¬¼Â¹Ô¤µ¤ì¤ë»þ¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£
612 ¤Ê¤¼¤Ê¤é¡¢´Ø¿ôÄêµÁ¼«¿È¤âÊ£¹ç¥³¥Þ¥ó¥É¤À¤«¤é¤Ç¤¹¡£
613 ¤½¤Î·ë²Ì¤È¤·¤Æ¡¢´Ø¿ôÆâ¤ÇÄêµÁ¤µ¤ì¤¿¥¨¥¤¥ê¥¢¥¹¤Ï¡¢¤½¤Î´Ø¿ô¤Î¼Â¹Ô¤µ¤ì¤ë¤Þ¤Ç¤Ï
614 ÍøÍѤǤ¤Þ¤»¤ó¡£°ÂÁ´¤Î¤¿¤á¡¢¥¨¥¤¥ê¥¢¥¹ÄêµÁ¤ÏÆÈΩ¤·¤¿¹Ô¤Ç¹Ô¤¦¤Ù¤¤Ç¤¹¡£
617 ¤ò»È¤Ã¤Æ¤Ï¤¤¤±¤Þ¤»¤ó¡£
619 .\"O For almost every purpose, aliases are superseded by
620 .\"O shell functions.
621 ¤Û¤È¤ó¤ÉÁ´¤Æ¤Î¾ì¹ç¤Ë¡¢¥¨¥¤¥ê¥¢¥¹¤ÎÂå¤ï¤ê¤Ë¥·¥§¥ë´Ø¿ô¤ò»È¤¦¤³¤È¤¬¤Ç¤¤Þ¤¹¡£