7 .\"O builtin is enabled, the shell provides access to the
8 .\"O \fIcommand history\fP,
9 .\"O the list of commands previously typed.
11 ¥ª¥×¥·¥ç¥ó¤òÁȤ߹þ¤ß¥³¥Þ¥ó¥É¤Î
14 \fI¥³¥Þ¥ó¥ÉÍúÎò (command history)\fP (°ÊÁ°¤ËÆþÎϤ·¤¿¥³¥Þ¥ó¥É¤Î¥ê¥¹¥È)
15 ¤Ë¥¢¥¯¥»¥¹¤Ç¤¤ë¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£
16 .\"O The value of the \fBHISTSIZE\fP variable is used as the
17 .\"O number of commands to save in a history list.
18 ÊÑ¿ô \fBHISTSIZE\fP ¤ÎÃͤ¬¡¢
19 ÍúÎò¥ê¥¹¥È¤ËÊݸ¤¹¤ë¥³¥Þ¥ó¥É¤Î¿ô¤Ë¤Ê¤ê¤Þ¤¹¡£
20 .\"WORD: history list ÍúÎò¥ê¥¹¥È
21 .\"O The text of the last
24 .\"O commands (default 500) is saved. The shell
25 .\"O stores each command in the history list prior to parameter and
26 .\"O variable expansion (see
29 .\"O above) but after history expansion is performed, subject to the
30 .\"O values of the shell variables
35 .\"O .BR HISTCONTROL .
36 ²áµî¤ËÆþÎϤ·¤¿¥³¥Þ¥ó¥É¤Î¤¦¤Á¡¢ºÇ¿·
39 ¸Äʬ (¥Ç¥Õ¥©¥ë¥È¤Ï 500 ¸Ä) ¤Î¥Æ¥¥¹¥È¤¬Êݸ¤µ¤ì¤Þ¤¹¡£
40 ¥·¥§¥ë¤Ï³Æ¥³¥Þ¥ó¥É¤ò¡¢¥Ñ¥é¥á¡¼¥¿Å¸³«¤äÊÑ¿ôŸ³«
44 ¤ò»²¾È) ¤ò¹Ô¤¦Á°¤Î¤«¤¿¤Á¤ÇÍúÎò¥ê¥¹¥È¤Ë³ÊǼ¤·¤Þ¤¹¡£
45 ¤¿¤À¤·¡¢ÍúÎòŸ³«¤Ï¼Â¹Ô¤·¤Æ¤«¤é³ÊǼ¤·¤Þ¤¹¡£
52 ¤ÎÃͤ˽¾¤Ã¤Æ¼Â¹Ô¤µ¤ì¤Þ¤¹¡£
54 .\"O On startup, the history is initialized from the file named by
58 .\"O (default \fI~/.bash_history\fP).
62 ÊÑ¿ô (¥Ç¥Õ¥©¥ë¥È¤Ï \fI~/.bash_history\fP)
63 ¤¬¼¨¤¹¥Õ¥¡¥¤¥ë¤ÎÆâÍƤǽé´ü²½¤µ¤ì¤Þ¤¹¡£
64 .\"O The file named by the value of
67 .\"O is truncated, if necessary, to contain no more than
68 .\"O the number of lines specified by the value of
70 .\"O .BR HISTFILESIZE .
73 ¤Ç»ØÄꤵ¤ì¤¿¥Õ¥¡¥¤¥ë¤Ï¡¢
76 ¤Ç»ØÄꤵ¤ì¤¿¹Ô¿ô¤ò±Û¤¨¤Ê¤¤¤è¤¦¤Ë¡¢É¬Íפ˱þ¤¸¤ÆÀÚ¤êµÍ¤á¤é¤ì¤Þ¤¹¡£
77 .\"O When an interactive shell exits, the last
80 .\"O lines are copied from the history list to
83 ÂÐÏÃŪ¤Ê¥·¥§¥ë¤¬½ªÎ»¤¹¤ëºÝ¤Ë¤Ï¡¢ºÇ¶á¤Î
86 ¸Ä¤Î¹Ô¤¬ÍúÎò¥ê¥¹¥È¤«¤é
92 .\"O shell option is enabled
93 .\"O (see the description of
97 .\"O .B "SHELL BUILTIN COMMANDS"
98 .\"O below), the lines are appended to the history file,
99 .\"O otherwise the history file is overwritten.
104 .B ¥·¥§¥ë¤ÎÁȤ߹þ¤ß¥³¥Þ¥ó¥É
107 ¤ÎÀâÌÀ¤ò»²¾È) ¤¬Í¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤È¡¢
108 ¤³¤ì¤é¤Î¹Ô¤ÏÍúÎò¥Õ¥¡¥¤¥ë¤ÎËöÈø¤ËÄɲ䵤ì¤Þ¤¹¡£
109 ¤³¤Î¥ª¥×¥·¥ç¥ó¤¬Ìµ¸ú¤Ê¤é¤Ð¡¢ÍúÎò¥Õ¥¡¥¤¥ë¤Ï¾å½ñ¤¤µ¤ì¤Þ¤¹¡£
113 .\"O is unset, or if the history file is unwritable, the history is
114 .\"O not saved. After saving the history, the history file is truncated
115 .\"O to contain no more than
121 .\"O is not set, no truncation is performed.
124 ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤¤¤«¡¢ÍúÎò¥Õ¥¡¥¤¥ë¤¬½ñ¤¹þ¤á¤Ê¤¤¾õÂÖ¤À¤È¡¢
125 ÍúÎò¤ÏÊݸ¤µ¤ì¤Þ¤»¤ó¡£
126 ÍúÎò¤ÎÊݸ¤ò¹Ô¤Ã¤¿¸å¤Ë¤Ï¡¢ÍúÎò¥Õ¥¡¥¤¥ë¤Ï¹Ô¿ô¤¬
129 ¹Ô¤ò±Û¤¨¤Ê¤¤¤è¤¦¤ËÀÚ¤êµÍ¤á¤é¤ì¤Þ¤¹¡£
132 ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢ÀÚ¤êµÍ¤á¤Ï¹Ô¤ï¤ì¤Þ¤»¤ó¡£
134 .\"O The builtin command
138 .\"O .B SHELL BUILTIN COMMANDS
139 .\"O below) may be used to list or edit and re-execute a portion of
140 .\"O the history list.
145 .B ¥·¥§¥ë¤ÎÁȤ߹þ¤ß¥³¥Þ¥ó¥É
146 ¤ò»²¾È) ¤òÍѤ¤¤ë¤È¡¢ÍúÎò¥ê¥¹¥È¤Î°ìÉô¤ò¥ê¥¹¥È¡¦ÊÔ½¸¤·¤ÆºÆ¼Â¹Ô¤Ç¤¤Þ¤¹¡£
149 .\"O builtin may be used to display or modify the history list and
150 .\"O manipulate the history file.
151 .\"O When using command-line editing, search commands
152 .\"O are available in each editing mode that provide access to the
156 ¤òÍѤ¤¤ë¤È¡¢ÍúÎò¥ê¥¹¥È¤òɽ¼¨¡¦ÊÔ½¸¤·¤¿¤ê¡¢
157 ÍúÎò¥Õ¥¡¥¤¥ë¤òÁàºî¤Ç¤¤Þ¤¹¡£
158 ¥³¥Þ¥ó¥É¥é¥¤¥ó¤òÊÔ½¸¤¹¤ëºÝ¤Ë¤Ï¡¢
159 ³ÆÊÔ½¸¥â¡¼¥É¤Ç¤¤¤í¤¤¤í¤Ê¸¡º÷¥³¥Þ¥ó¥É¤¬ÍøÍѤǤ¡¢
160 ÍúÎò¥ê¥¹¥È¤Ø¥¢¥¯¥»¥¹¤Ç¤¤Þ¤¹¡£
162 .\"O The shell allows control over which commands are saved on the history
169 .\"O variables may be set to cause the shell to save only a subset of the
170 .\"O commands entered.
171 ¤³¤Î¥·¥§¥ë¤Ç¤Ï¡¢¤É¤Î¥³¥Þ¥ó¥É¤¬ÍúÎò¥ê¥¹¥È¤ËÊݸ¤µ¤ì¤ë¤«¤òÀ©¸æ¤Ç¤¤Þ¤¹¡£
178 ¥·¥§¥ë¤ÏÆþÎϤµ¤ì¤¿¥³¥Þ¥ó¥É¤Î°ìÉô¤·¤«Êݸ¤·¤Ê¤¯¤Ê¤ê¤Þ¤¹¡£
181 .\"O shell option, if enabled, causes the shell to attempt to save each
182 .\"O line of a multi-line command in the same history entry, adding
183 .\"O semicolons where necessary to preserve syntactic correctness.
186 ¤ò͸ú¤Ë¤¹¤ë¤È¡¢¥·¥§¥ë¤ÏÊ£¿ô¹Ô¤ËÊ̤ì¤Æ¤¤¤ë¥³¥Þ¥ó¥É¤Î³Æ¹Ô¤ò
187 Ʊ¤¸ÍúÎò¥¨¥ó¥È¥ê¤ËÊݸ¤·¤è¤¦¤È¤·¤Þ¤¹¡£
188 ¤³¤ÎºÝ¤Ë¤Ï¡¢Ê¸Ë¡Åª¤ÊÀµ¤·¤µ¤òÊݤĤ¿¤á¤Ë¥»¥ß¥³¥í¥ó¤¬É¬Íפ˱þ¤¸¤ÆÄɲ䵤ì¤Þ¤¹¡£
191 .\"O shell option causes the shell to save the command with embedded newlines
192 .\"O instead of semicolons. See the description of the
194 .\"O builtin below under
196 .\"O .B "SHELL BUILTIN COMMANDS"
197 .\"O for information on setting and unsetting shell options.
200 ¤ò͸ú¤Ë¤¹¤ë¤È¡¢¤³¤Î¥·¥§¥ë¤Ï¹Ô¤ÎÅÓÃæ¤Ë
201 ¥»¥ß¥³¥í¥ó¤Ç¤Ï¤Ê¤¯²þ¹Ôʸ»ú¤òÃÖ¤¯·Á¤Ç¥³¥Þ¥ó¥É¤òÊݸ¤·¤Þ¤¹¡£
202 ¥·¥§¥ë¥ª¥×¥·¥ç¥ó¤ÎÀßÄê¤ÈÀßÄê¼è¤ê¾Ã¤·¤Ë¤Ä¤¤¤Æ¤Ï¡¢¸å½Ò¤Î
204 .B ¥·¥§¥ë¤ÎÁȤ߹þ¤ß¥³¥Þ¥ó¥É
205 ¤Ë¤ª¤±¤ëÀâÌÀ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£
206 .\"O .SH "HISTORY EXPANSION"
209 .\"O The shell supports a history expansion feature that
210 .\"O is similar to the history expansion in
212 .\"O This section describes what syntax features are available. This
213 .\"O feature is enabled by default for interactive shells, and can be
214 .\"O disabled using the
218 .\"O builtin command (see
220 .\"O .B SHELL BUILTIN COMMANDS
221 .\"O below). Non-interactive shells do not perform history expansion
225 ¤ÎÍúÎòŸ³«¤ÈƱ¤¸¤è¤¦¤Êµ¡Ç½¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Þ¤¹¡£
226 ¤³¤Î¥»¥¯¥·¥ç¥ó¤Ç¤Ï¡¢ÍúÎòŸ³«¤Ç»ÈÍѤǤ¤ëµË¡¡¦µ¡Ç½¤òÀâÌÀ¤·¤Þ¤¹¡£
227 ¤³¤Îµ¡Ç½¤ÏÂÐÏÃŪ¥·¥§¥ë¤Ê¤é¤Ð¥Ç¥Õ¥©¥ë¥È¤Ç͸ú¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¤¬¡¢
234 .B ¥·¥§¥ë¤ÎÁȤ߹þ¤ß¥³¥Þ¥ó¥É
235 ¤ò»²¾È) ¤Ç̵¸ú¤Ë¤Ç¤¤Þ¤¹¡£
236 ÈóÂÐÏÃŪ¥·¥§¥ë¤Î¾ì¹ç¤Ï¡¢¥Ç¥Õ¥©¥ë¥È¤Ç¤ÏÍúÎòŸ³«¤Ï¹Ô¤ï¤ì¤Þ¤»¤ó¡£
238 .\"O History expansions introduce words from the history list into
239 .\"O the input stream, making it easy to repeat commands, insert the
240 .\"O arguments to a previous command into the current input line, or
241 .\"O fix errors in previous commands quickly.
242 ÍúÎòŸ³«¤Ï¡¢ÍúÎò¥ê¥¹¥ÈÃæ¤Îñ¸ì¤òÆþÎÏ¥¹¥È¥ê¡¼¥à¤ËÆþ¤ì¤Þ¤¹¡£
243 ¤³¤Îµ¡Ç½¤òÍøÍѤ¹¤ë¤È¡¢¥³¥Þ¥ó¥É¤ò·«¤êÊÖ¤·¤¿¤ê¡¢
244 Á°¤Î¥³¥Þ¥ó¥É¤Ç»ØÄꤷ¤¿¥ª¥×¥·¥ç¥ó¤ò¸½ºß¤ÎÆþÎϹԤËÁÞÆþ¤·¤¿¤ê¡¢
245 Á°¤Î¥³¥Þ¥ó¥É¤Î¸í¤ê¤ò¼êÁ᤯ľ¤·¤¿¤ê¡¢
246 ¤È¤¤¤Ã¤¿¤³¤È¤¬´Êñ¤Ë¤Ç¤¤ë¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£
248 .\"O History expansion is performed immediately after a complete line
249 .\"O is read, before the shell breaks it into words.
250 .\"O It takes place in two parts.
251 .\"O The first is to determine which line from the history list
252 .\"O to use during substitution.
253 .\"O The second is to select portions of that line for inclusion into
254 .\"O the current one.
255 ÍúÎòŸ³«¤¬¼Â¹Ô¤µ¤ì¤ë¤Î¤ÏÆþÎϹÔÁ´ÂΤòÆɤ߹þ¤ó¤Àľ¸å¤Ç¤¢¤ê¡¢
256 ¥·¥§¥ë¤¬¹Ô¤òñ¸ì¤Ëʬ³ä¤¹¤ë¤è¤ê¤âÁ°¤Ç¤¹¡£
257 ÍúÎòŸ³«¤ÎÆ°ºî¤Ï 2 Ãʳ¬¤Ç¹Ô¤ï¤ì¤Þ¤¹¡£
258 ¤Þ¤ººÇ½é¤Ë¡¢ÃÖ´¹¤Ë»È¤¦¹Ô¤òÍúÎò¥ê¥¹¥È¤«¤éÁª¤Ó¤Þ¤¹¡£
259 ¼¡¤Ë¡¢¤½¤Î¹Ô¤Î¤É¤ÎÉôʬ¤ò¸½ºß¤Î¹Ô¤Ë½ñ¤¹þ¤à¤«¤òÁªÂò¤·¤Þ¤¹¡£
260 .\"O The line selected from the history is the \fIevent\fP,
261 .\"O and the portions of that line that are acted upon are \fIwords\fP.
262 .\"O Various \fImodifiers\fP are available to manipulate the selected words.
263 ÍúÎò¥ê¥¹¥È¤«¤éÁª¤Ð¤ì¤¿¹Ô¤Ï\fI¥¤¥Ù¥ó¥È (event)\fP ¤È¸Æ¤Ð¤ì¡¢
264 ¤³¤Î¹Ô¤Î¤¦¤ÁÆ°ºî¤ÎÂоݤȤʤëÉôʬ¤ò\fIñ¸ìÎó (words)\fP¤È¸Æ¤Ó¤Þ¤¹¡£
265 ÍÍ¡¹¤Ê\fI½¤¾þ»Ò (modifier)\fP ¤¬ÍøÍѤǤ¡¢
266 ÁªÂò¤µ¤ì¤¿Ã±¸ìÎó¤ÎÁàºî¤¬²Äǽ¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£
267 .\"O The line is broken into words in the same fashion as when reading input,
268 .\"O so that several \fImetacharacter\fP-separated words surrounded by
269 .\"O quotes are considered one word.
270 ¹Ô¤Îñ¸ì¤Ø¤Îʬ³ä¤ÏÆþÎϤòÆɤ߹þ¤à»þ¤ÈƱ¤¸¤è¤¦¤Ë¹Ô¤ï¤ì¤ë¤Î¤Ç¡¢
271 \fI¥á¥¿Ê¸»ú\fP¤Ç¶èÀÚ¤é¤ì¤¿Ê£¿ô¤Îñ¸ì¤ò¥¯¥©¡¼¥È¤Ç³ç¤Ã¤¿¤â¤Î¤Ï
272 1 ¤Ä¤Îñ¸ì¤È¸«¤Ê¤µ¤ì¤Þ¤¹¡£
273 .\"O History expansions are introduced by the appearance of the
274 .\"O history expansion character, which is \^\fB!\fP\^ by default.
275 .\"O Only backslash (\^\fB\e\fP\^) and single quotes can quote
276 .\"O the history expansion character.
277 ÍúÎòŸ³«¤¬¹Ô¤ï¤ì¤ë¤Î¤Ï¡¢ÍúÎòŸ³«Ê¸»ú¤¬¸½¤ï¤ì¤¿»þ¤Ç¤¹¡£
278 ÍúÎòŸ³«Ê¸»ú¤Ï¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï \^\fB!\fP\^ ¤Ç¤¹¡£
279 ÍúÎòŸ³«Ê¸»ú¤ò¥¯¥©¡¼¥È¤Ç¤¤ë¤Î¤Ï¡¢
280 ¥Ð¥Ã¥¯¥¹¥é¥Ã¥·¥å (\^\fB\e\fP\^) ¤È¥·¥ó¥°¥ë¥¯¥©¡¼¥È¤À¤±¤Ç¤¹¡£
282 .\"O Several shell options settable with the
284 .\"O builtin may be used to tailor the behavior of history expansion.
287 ¤òÍѤ¤¤Æ¡¢²¿¼ïÎफ¤¢¤ë¥·¥§¥ë¥ª¥×¥·¥ç¥ó¤òÀßÄꤹ¤ë¤È¡¢
288 ÍúÎòŸ³«¤ÎÆ°ºî¤òÄ´À°¤Ç¤¤Þ¤¹¡£
291 .\"O shell option is enabled (see the description of the
295 .\"O is being used, history substitutions are not immediately passed to
296 .\"O the shell parser.
299 ¤¬Í¸ú¤Ç (ÁȤ߹þ¤ß¥³¥Þ¥ó¥É
303 ¤¬»È¤ï¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï¡¢
304 ÍúÎòÃÖ´¹¤ò¹Ô¤Ã¤¿·ë²Ì¤Ï¤¹¤°¤Ë¤Ï¥·¥§¥ë¤Î¥Ñ¡¼¥¶¤ËÅϤµ¤ì¤Þ¤»¤ó¡£
305 .\"O Instead, the expanded line is reloaded into the
307 .\"O editing buffer for further modification.
310 ¤ÎÊÔ½¸¥Ð¥Ã¥Õ¥¡¤ËºÆ¤ÓÆɤ߹þ¤Þ¤ì¡¢¤µ¤é¤ËÊÔ½¸¤¬¹Ô¤¨¤ë¾õÂ֤ˤʤê¤Þ¤¹¡£
313 .\"O is being used, and the
315 .\"O shell option is enabled, a failed history substitution will be reloaded
318 .\"O editing buffer for correction.
320 ¤ò»ÈÍѤ·¤Æ¤ª¤ê¡¢¤«¤Ä¥·¥§¥ë¥ª¥×¥·¥ç¥ó¤Î
322 ¤¬Í¸ú¤Ç¤¢¤ë¾ì¹ç¡¢ÍúÎòÃÖ´¹¤¬¼ºÇÔ¤·¤Æ¤â¤½¤Î·ë²Ì¤Ï
324 ¤ÎÊÔ½¸¥Ð¥Ã¥Õ¥¡¤ËºÆ¤ÓÆɤ߹þ¤Þ¤ì¡¢ÄûÀµ¤Ç¤¤ë¾õÂ֤Ȥʤê¤Þ¤¹¡£
329 .\"O builtin command may be used to see what a history expansion will
330 .\"O do before using it.
335 ¥ª¥×¥·¥ç¥ó¤ò»È¤¦¤È¡¢¼ÂºÝ¤ËÍúÎòŸ³«¤ò¹Ô¤¦Á°¤Ë¡¢
336 ¤É¤Î¤è¤¦¤ËŸ³«¤µ¤ì¤ë¤Î¤«¤ò¸«¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£
341 .\"O builtin may be used to add commands to the end of the history list
342 .\"O without actually executing them, so that they are available for
343 .\"O subsequent recall.
349 ¥³¥Þ¥ó¥É¤òÍúÎò¥ê¥¹¥È¤ÎËöÈø¤Ë (¼ÂºÝ¤Î¼Â¹Ô¤Ï¤»¤º¤Ë) ÄɲäǤ¤Þ¤¹¡£
350 Äɲä·¤¿¥³¥Þ¥ó¥É¤Ï¡¢¸å¤ÇºÆ¸Æ¤Ó½Ð¤·¤Ç¤¤Þ¤¹¡£
352 .\"O The shell allows control of the various characters used by the
353 .\"O history expansion mechanism (see the description of
356 .\"O .BR "Shell Variables" ).
357 ¤³¤Î¥·¥§¥ë¤Ç¤Ï¡¢ÍúÎòŸ³«µ¡¹½¤Ç»È¤¦¤¤¤í¤¤¤í¤Êʸ»ú¤òÀ©¸æ¤Ç¤¤Þ¤¹
362 ¤ÎÀâÌÀ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤)¡£
363 .\"O .SS Event Designators
364 .SS ¥¤¥Ù¥ó¥È»Ø¼¨»Ò (Event Designator)
366 .\"O An event designator is a reference to a command line entry in the
369 ÍúÎò¥ê¥¹¥ÈÃæ¤Î¥³¥Þ¥ó¥É¥é¥¤¥ó¥¨¥ó¥È¥ê¤ò»²¾È¤¹¤ë¤â¤Î¤Ç¤¹¡£
374 .\"O Start a history substitution, except when followed by a
376 .\"O newline, = or (.
377 ÍúÎòÃÖ´¹¤ò³«»Ï¤·¤Þ¤¹¡£¤¿¤À¤·¡¢\fB¥Ö¥é¥ó¥¯Ê¸»ú\fR¡¢
378 ²þ¹Ôʸ»ú¡¢=, ( ¤Î¤¤¤º¤ì¤«¤¬¸å¤Ë³¤¯¾ì¹ç¤Ï½ü¤¤Þ¤¹¡£
381 .\"O Refer to command line
384 ¹ÔÌܤΥ³¥Þ¥ó¥É¥é¥¤¥ó¤ò»²¾È¤·¤Þ¤¹¡£
387 .\"O Refer to the current command line minus
391 ¹ÔÁ°¤Î¥³¥Þ¥ó¥É¥é¥¤¥ó¤ò»²¾È¤·¤Þ¤¹¡£
394 .\"O Refer to the previous command. This is a synonym for `!\-1'.
395 1 ¹ÔÁ°¤Î¥³¥Þ¥ó¥É¥é¥¤¥ó¤ò»²¾È¤·¤Þ¤¹¡£`!\-1' ¤ÈƱµÁ¤Ç¤¹¡£
398 .\"O Refer to the most recent command starting with
401 ¤Ç»Ï¤Þ¤ë¥³¥Þ¥ó¥É¤Î¤¦¤Á¡¢°ìÈÖ¸½ºß¤Ë¶á¤¤¤È¤³¤í¤Ç¼Â¹Ô¤·¤¿¤â¤Î¤ò»²¾È¤·¤Þ¤¹¡£
403 .B !?\fIstring\fR\fB[?]\fR
404 .\"O Refer to the most recent command containing
406 .\"O The trailing \fB?\fP may be omitted if
408 .\"O is followed immediately by a newline.
410 ¤ò´Þ¤à¥³¥Þ¥ó¥É¤Î¤¦¤Á¡¢°ìÈÖ¸½ºß¤Ë¶á¤¤¤È¤³¤í¤Ç¼Â¹Ô¤·¤¿¤â¤Î¤ò»²¾È¤·¤Þ¤¹¡£
412 ¤Îľ¸å¤¬²þ¹Ôʸ»ú¤Ê¤é¤Ð¡¢ºÇ¸å¤Î \fB?\fP ¤Ï¾Êά¤·¤Æ¤â¹½¤¤¤Þ¤»¤ó¡£
414 .B \d\s+2^\s-2\u\fIstring1\fP\d\s+2^\s-2\u\fIstring2\fP\d\s+2^\s-2\u
415 .\"O Quick substitution. Repeat the last command, replacing
420 .\"O ``!!:s/\fIstring1\fP/\fIstring2\fP/''
421 .\"O (see \fBModifiers\fP below).
426 ¤ËÃÖ´¹¤·¤ÆľÁ°¤Î¥³¥Þ¥ó¥É¤ò·«¤êÊÖ¤·¤Þ¤¹¡£
427 ``!!:s/\fIstring1\fP/\fIstring2\fP/'' ¤ÈƱµÁ¤Ç¤¹
428 (¸å½Ò¤Î\fB½¤¾þ»Ò\fP¤ò»²¾È)¡£
431 .\"O The entire command line typed so far.
432 º£¤Þ¤Ç¤Î¤È¤³¤í¤Þ¤Ç¤ËÂǤÁ¹þ¤ó¤À¥³¥Þ¥ó¥É¥é¥¤¥óÁ´ÂΤǤ¹¡£
434 .\"O .SS Word Designators
435 .SS ñ¸ì»Ø¼¨»Ò(Word Designators)
437 .\"O Word designators are used to select desired words from the event.
440 .\"O separates the event specification from the word designator.
441 .\"O It may be omitted if the word designator begins with a
448 .\"O Words are numbered from the beginning of the line,
449 .\"O with the first word being denoted by 0 (zero).
450 .\"O Words are inserted into the current line separated by single spaces.
451 ñ¸ì»Ø¼¨»Ò (word designator) ¤Ï¡¢
452 ¥¤¥Ù¥ó¥È¤«¤éÍߤ·¤¤Ã±¸ì¤òÁª¤Ö»þ¤ËÍѤ¤¤é¤ì¤Þ¤¹¡£
453 ¥¤¥Ù¥ó¥È»ØÄê¤Èñ¸ì»Ø¼¨»Ò¤Î¥»¥Ñ¥ì¡¼¥¿¤Ë¤Ï
462 ¤Î¤¤¤º¤ì¤«¤Ç»Ï¤Þ¤ë¾ì¹ç¤Ë¤Ï¡¢¤³¤Î¥»¥Ñ¥ì¡¼¥¿¤Ï¾Êά¤Ç¤¤Þ¤¹¡£
463 ñ¸ì¤Ë¤Ï¹Ô¤ÎÀèƬ¤«¤éÈֹ椬¿¶¤é¤ì¤Þ¤¹¡£
464 ÀèƬ¤Îñ¸ì¤¬ 0 ÈÖÌܤˤʤê¤Þ¤¹¡£
465 ñ¸ì¤Ï¸½ºß¤Î¹Ô¤Ë¡¢¶õÇò 1 ¤Ä¤Ç¶èÀÚ¤é¤ì¤ÆÁÞÆþ¤µ¤ì¤Þ¤¹¡£
471 .\"O The zeroth word. For the shell, this is the command
473 0 ÈÖÌܤÎñ¸ì¡£¤³¤Î¥·¥§¥ë¤Ë¤È¤Ã¤Æ¤Ï¡¢¤³¤ì¤Ï¥³¥Þ¥ó¥É¤òɽ¤¹Ã±¸ì¤Ç¤¹¡£
476 .\"O The \fIn\fRth word.
480 .\"O The first argument. That is, word 1.
481 ºÇ½é¤Î°ú¤¿ô¡£¤Ä¤Þ¤ê 1 ÈÖÌܤÎñ¸ì¤Ç¤¹¡£
484 .\"O The last argument.
488 .\"O The word matched by the most recent `?\fIstring\fR?' search.
489 `?\fIstring\fR?' ¸¡º÷¤Ë¥Þ¥Ã¥Á¤¹¤ë¡¢°ìÈÖ¸½ºß¤Ë¶á¤¤Ã±¸ì¡£
492 .\"O A range of words; `\-\fIy\fR' abbreviates `0\-\fIy\fR'.
493 ñ¸ì¤ÎÈÏ°Ï¡£`0\-\fIy\fR' ¤Î¾Êά·Á¤È¤·¤Æ `\-\fIy\fR' ¤¬»È¤¨¤Þ¤¹¡£
496 .\"O All of the words but the zeroth. This is a synonym
497 .\"O for `\fI1\-$\fP'. It is not an error to use
499 .\"O if there is just one
500 .\"O word in the event; the empty string is returned in that case.
501 0 ÈÖÌܤò½ü¤¯Á´¤Æ¤Îñ¸ì¡£¤³¤ì¤Ï `\fI1\-$\fP' ¤ÎÊÌɽ¸½¤Ç¤¹¡£
502 ¥¤¥Ù¥ó¥ÈÃæ¤Ë 1 ¤Ä¤·¤«Ã±¸ì¤¬¸½¤ï¤ì¤Ê¤¤¤È¤¤Ë
504 ¤ò»È¤Ã¤Æ¤â¥¨¥é¡¼¤Ë¤Ï¤Ê¤ê¤Þ¤»¤ó¡£
505 ¤³¤Î¤è¤¦¤Ê¾ì¹ç¤Ë¤Ï¶õʸ»úÎó¤¬ÊÖ¤µ¤ì¤Þ¤¹¡£
508 .\"O Abbreviates \fIx\-$\fP.
509 \fIx\-$\fP ¤Î¾Êά·Á¤Ç¤¹¡£
512 .\"O Abbreviates \fIx\-$\fP like \fBx*\fP, but omits the last word.
513 \fBx*\fP ¤ÈƱÍÍ¤Ë \fIx\-$\fP ¤Î¾Êά·Á¤Ç¤¹¤¬¡¢
514 ¤¿¤À¤·ºÇ¸å¤Îñ¸ì¤Ï´Þ¤ß¤Þ¤»¤ó¡£
517 .\"O If a word designator is supplied without an event specification, the
518 .\"O previous command is used as the event.
519 ¥¤¥Ù¥ó¥È»ØÄê¤Ê¤·¤Ëñ¸ì»Ø¼¨»Ò¤¬Í¿¤¨¤é¤ì¤¿¾ì¹ç¡¢
520 ľÁ°¤Î¥³¥Þ¥ó¥É¤¬¥¤¥Ù¥ó¥È¤È¤·¤Æ»È¤ï¤ì¤Þ¤¹¡£
522 .SS ½¤¾þ»Ò(Modifiers)
524 .\"O After the optional word designator, there may appear a sequence of
525 .\"O one or more of the following modifiers, each preceded by a `:'.
526 ñ¸ì»Ø¼¨»Ò (¾Êά²Äǽ) ¤Î¸å¤Ë¤Ï¡¢
527 °Ê²¼¤Ë¼¨¤¹½¤¾þ»Ò¤ò¡¢1 ¸Ä°Ê¾å¤Î¥·¡¼¥±¥ó¥¹¤Î¤«¤¿¤Á¤ÇÃÖ¤¯¤³¤È¤¬¤Ç¤¤Þ¤¹¡£
528 ¤½¤ì¤¾¤ì¤Î½¤¾þ»Ò¤ÎÁ°¤Ë¤Ï `:' ¤ò¤Ä¤±¤Þ¤¹¡£
534 .\"O Remove a trailing file name component, leaving only the head.
535 ¥Ñ¥¹Ì¾¤«¤éËöÈø¤Ë¤¢¤ëÉôʬ (¥Õ¥¡¥¤¥ë̾) ¤ò¼è¤ê½ü¤¡¢
536 Á°¤ÎÊý (¥Ç¥£¥ì¥¯¥È¥êÉô) ¤À¤±¤ò»Ä¤·¤Þ¤¹¡£
539 .\"O Remove all leading file name components, leaving the tail.
540 ¥Ñ¥¹Ì¾¤«¤éÁ°¤ÎÊý (¥Ç¥£¥ì¥¯¥È¥êÉô) ¤ò¼è¤ê½ü¤¡¢
541 ËöÈø¤Ë¤¢¤ëÉôʬ (¥Õ¥¡¥¤¥ë̾) ¤À¤±¤ò»Ä¤·¤Þ¤¹¡£
544 .\"O Remove a trailing suffix of the form \fI.xxx\fP, leaving the
546 ËöÈø¤Ë¤¢¤ë \fI.xxx\fP ·Á¼°¤Î¥µ¥Õ¥£¥Ã¥¯¥¹¤ò¼è¤ê½ü¤¡¢
547 ¥Ù¡¼¥¹Ì¾ (basename) ¤À¤±¤ò»Ä¤·¤Þ¤¹¡£
550 .\"O Remove all but the trailing suffix.
551 ËöÈø¤Î¥µ¥Õ¥£¥Ã¥¯¥¹¤À¤±¤ò»Ä¤·¤Æ¡¢Á´¤Æ¤ÎÉôʬ¤ò¼è¤ê½ü¤¤Þ¤¹¡£
554 .\"O Print the new command but do not execute it.
555 ¿·¤·¤¤¥³¥Þ¥ó¥É¤òɽ¼¨¤·¤Þ¤¹¤¬¡¢¼Â¹Ô¤Ï¤·¤Þ¤»¤ó¡£
558 .\"O Quote the substituted words, escaping further substitutions.
559 ÃÖ´¹¤¬¹Ô¤ï¤ì¤¿Ã±¸ì¤ò¥¯¥©¡¼¥È¤·¡¢¤½¤ì°Ê¾å¤ÎÃÖ´¹¤¬¹Ô¤ï¤ì¤Ê¤¤¤è¤¦¤Ë¤·¤Þ¤¹¡£
562 .\"O Quote the substituted words as with
564 .\"O but break into words at
568 ¤ÈƱ¤¸¤è¤¦¤ËÃÖ´¹¸å¤Îñ¸ì¤ò¥¯¥©¡¼¥È¤·¤Þ¤¹¤¬¡¢
570 ¤È²þ¹Ôʸ»ú¤Î¤È¤³¤í¤Çñ¸ì¤Ëʬ³ä¤·¤Þ¤¹¡£
572 .B s/\fIold\fP/\fInew\fP/
575 .\"O for the first occurrence of
577 .\"O in the event line. Any delimiter can be used in place of /. The
578 .\"O final delimiter is optional if it is the last character of the
579 .\"O event line. The delimiter may be quoted in
583 .\"O with a single backslash. If & appears in
585 .\"O it is replaced by
587 ¥¤¥Ù¥ó¥È¹Ô¤ÇºÇ½é¤Ë¸½¤ï¤ì¤¿
591 ¤ËÃÖ¤´¹¤¨¤Þ¤¹¡£/ ¤ÎÂå¤ï¤ê¤ËǤ°Õ¤Î¶èÀÚ¤êʸ»ú¤ò»È¤¦¤³¤È¤â¤Ç¤¤Þ¤¹¡£
592 ºÇ¸å¤Î¶èÀÚ¤êʸ»ú¤¬¥¤¥Ù¥ó¥È¹Ô¤ÎºÇ¸å¤Îʸ»ú¤Ê¤é¤Ð¡¢
598 ¥Ð¥Ã¥¯¥¹¥é¥Ã¥·¥å 1 ¤Ä¤Ç¥¯¥©¡¼¥È¤¹¤ì¤Ð¶èÀÚ¤êʸ»ú¤â»È¤¨¤Þ¤¹¡£
600 ¤Ë & ¤¬´Þ¤Þ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï¡¢¤³¤ì¤Ï
603 .\"O A single backslash will quote the &. If
605 .\"O is null, it is set to the last
607 .\"O substituted, or, if no previous history substitutions took place,
611 .\"O .B !?\fIstring\fR\fB[?]\fR
613 ¥Ð¥Ã¥¯¥¹¥é¥Ã¥·¥å 1 ¤Ä¤òÁ°¤ËÃÖ¤±¤Ð & ¤ò¥¯¥©¡¼¥È¤Ç¤¤Þ¤¹¡£
615 ¤¬¶õʸ»úÎó¤Ê¤é¤Ð¡¢¤³¤ì¤Ë¤ÏÁ°²ó¤ËÃÖ´¹¤µ¤ì¤¿
618 °ÊÁ°¤ËÍúÎòÃÖ´¹¤¬Á´¤¯¹Ô¤ï¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ë¤Ï¡¢¸½ºß¤Ë°ìÈֶᤤ
619 .B !?\fIstring\fR\fB[?]\fR
625 .\"O Repeat the previous substitution.
626 ľÁ°¤ÎÃÖ´¹¤ò·«¤êÊÖ¤·¤Þ¤¹¡£
629 .\"O Cause changes to be applied over the entire event line. This is
630 .\"O used in conjunction with `\fB:s\fP' (e.g., `\fB:gs/\fIold\fP/\fInew\fP/\fR')
631 .\"O or `\fB:&\fP'. If used with
632 .\"O `\fB:s\fP', any delimiter can be used
633 .\"O in place of /, and the final delimiter is optional
634 .\"O if it is the last character of the event line.
635 Êѹ¹¤ò¥¤¥Ù¥ó¥È¹ÔÁ´ÂΤËŬÍѤ·¤Þ¤¹¡£
636 ¤³¤ì¤Ï `\fB:s\fP' ¤ÈÁȤ߹ç¤ï¤»¤Æ»È¤ï¤ì¤Þ¤¹
637 (Îã:`\fB:gs/\fIold\fP/\fInew\fP/\fR')¡£
638 `\fB:s\fP' ¤È°ì½ï¤Ë»È¤Ã¤¿¾ì¹ç¤Ë¤Ï¡¢
639 / ¤ÎÂå¤ï¤ê¤ËǤ°Õ¤Î¶èÀÚ¤êʸ»ú¤ò»È¤¦¤³¤È¤¬¤Ç¤¤Þ¤¹¡£
640 ¤Þ¤¿ºÇ¸å¤Î¶èÀÚ¤êʸ»ú¤¬¥¤¥Ù¥ó¥È¹Ô¤ÎºÇ¸å¤Îʸ»ú¤Ê¤é¤Ð¡¢