OSDN Git Service

Import translated manuals from JM CVS Repository.
[linuxjm/jm.git] / manual / GNU_sed / draft / man1 / sed.1
1 .\"
2 .\" sed.1 - the *roff document processor source for the sed manual
3 .\"
4 .\" This file is part of GNU sed.
5 .\" Copyright (C) 1998 Free Software Foundation, Inc.
6 .\"
7 .\" This program is free software; you can redistribute it and/or modify
8 .\" it under the terms of the GNU General Public License as published by
9 .\" the Free Software Foundation; either version 2, or (at your option)
10 .\" any later version.
11 .\"
12 .\" This program is distributed in the hope that it will be useful,
13 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
14 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 .\" GNU General Public License for more details.
16 .\"
17 .\" You should have received a copy of the GNU General Public License
18 .\" along with this program; if not, write to the Free Software
19 .\" Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20 .\"
21 .\" Japanese Version Copyright (c) 2001 NAKANO Takeo all rights reserved.
22 .\" Translated Mon 7 May 2001 by NAKANO Takeo <nakano@apm.seikei.ac.jp>
23 .\"
24 .TH SED 1 "1998-05-07" "GNU Project"
25 .ds sd \fIsed\fP
26 .\"O .ds Sd \fISed\fP
27 .\"O .SH NAME
28 .\"O sed \- a Stream EDitor
29 .SH Ì¾Á°
30 sed \- ¥¹¥È¥ê¡¼¥à¥¨¥Ç¥£¥¿
31 .\"O .SH SYNOPSIS
32 .SH ½ñ¼°
33 .nf
34 sed [-n] [-V] [--quiet] [--silent] [--version] [--help]
35     [-e script] [--expression=script]
36     [-f script-file] [--file=script-file]
37     [script-if-no-other-script]
38     [file...]
39 .fi
40 .\"O .SH DESCRIPTION
41 .SH ÀâÌÀ
42 .\"O \*(Sd is a stream editor.
43 .\"O A stream editor is used to perform basic text
44 .\"O transformations on an input stream
45 .\"O (a file or input from a pipeline).
46 .\"O While in some ways similar to an editor which
47 .\"O permits scripted edits (such as \fIed\fP),
48 .\"O \*(sd works by making only one pass over the
49 .\"O input(s), and is consequently more efficient.
50 .\"O But it is \*(sd's ability to filter text in a pipeline
51 .\"O which particularly distinguishes it from other types of
52 .\"O editors.
53 \*(sd ¤Ï¥¹¥È¥ê¡¼¥à¥¨¥Ç¥£¥¿¤Ç¤¢¤ë¡£
54 ¥¹¥È¥ê¡¼¥à¥¨¥Ç¥£¥¿¤Ï¡¢ÆþÎÏ¥¹¥È¥ê¡¼¥à
55 (¥Õ¥¡¥¤¥ë¤Þ¤¿¤Ï¥Ñ¥¤¥×¥é¥¤¥ó¤«¤é¤ÎÆþÎÏ)
56 ¤ËÂФ·¤Æ´ðËÜŪ¤Ê¥Æ¥­¥¹¥ÈÊÑ´¹¤ò¹Ô¤¦¤¿¤á¤ËÍѤ¤¤é¤ì¤ë¡£
57 \*(sd ¤Ï
58 ÊÔ½¸¥¹¥¯¥ê¥×¥È¤ò»È¤¨¤ë (\fIed\fP ¤Î¤è¤¦¤Ê) ¥¨¥Ç¥£¥¿¤È
59 ¤¤¤í¤¤¤í¤ÊÌ̤ǻ÷¤Æ¤¤¤ë¤¬¡¢
60 \*(sd ¤ÏÆþÎϤËÂФ·¤Æ 1 ¥Ñ¥¹¤À¤±¤ÇÆ°ºî¤¹¤ë¤Î¤Ç¡¢¤è¤ê¸úΨŪ¤Ç¤¢¤ë¡£
61 ¤Þ¤¿ \*(sd ¤Ï¥Ñ¥¤¥×¥é¥¤¥ó¤Î¥Æ¥­¥¹¥È¤ËÂФ·¤Æ¥Õ¥£¥ë¥¿Æ°ºî¤ò¹Ô¤¦¤³¤È¤¬¤Ç¤­¡¢
62 ¤³¤ÎÅÀ¤Ï¾¤Î¥¿¥¤¥×¤Î¥¨¥Ç¥£¥¿¤È¤Ï¤Ã¤­¤ê°ã¤¦¡£
63
64 .\"O .SH OPTIONS
65 .SH ¥ª¥×¥·¥ç¥ó
66 .\"O \*(Sd may be invoked with the following command-line options:
67 \*(sd ¤Îµ¯Æ°»þ¤Ë¤Ï°Ê²¼¤Î¥³¥Þ¥ó¥É¥é¥¤¥ó¥ª¥×¥·¥ç¥ó¤ò»ØÄê¤Ç¤­¤ë¡£
68 .TP
69 .B -V
70 .TP
71 .B --version
72 .\"O Print out the version of sed that is being run and a copyright notice,
73 .\"O then exit.
74 sed ¤Î¥Ð¡¼¥¸¥ç¥ó¡¦Ãøºî¸¢É½¼¨¤ò½ÐÎϤ·¡¢½ªÎ»¤¹¤ë¡£
75 .TP
76 .B -h
77 .TP
78 .B --help
79 .\"O Print a usage message briefly summarizing these command-line options
80 .\"O and the bug-reporting address,
81 .\"O then exit.
82 ¥³¥Þ¥ó¥É¥é¥¤¥ó¥ª¥×¥·¥ç¥ó¤ò´Êñ¤Ë¤Þ¤È¤á¤¿ÍøÍÑË¡¤È
83 ¥Ð¥°¥ì¥Ý¡¼¥ÈÀè¤Î¥¢¥É¥ì¥¹¤ò½ÐÎϤ·¡¢½ªÎ»¤¹¤ë¡£
84 .TP
85 .B -n
86 .TP
87 .B --quiet
88 .TP
89 .B --silent
90 .\"O By default, \*(sd will print out the pattern space
91 .\"O at the end of each cycle through the script.
92 .\"O These options disable this automatic printing,
93 .\"O and \*(sd will only produce output when explicitly told to
94 .\"O via the
95 .\"O .B p
96 .\"O command.
97 ¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï¡¢
98 \*(sd ¤Ï¥¹¥¯¥ê¥×¥È¤Î³Æ¥µ¥¤¥¯¥ë¤ÎºÇ¸å¤Ç¥Ñ¥¿¡¼¥ó¥¹¥Ú¡¼¥¹¤ÎÆâÍƤò½ÐÎϤ¹¤ë¡£
99 ¤³¤ì¤é¤Î¥ª¥×¥·¥ç¥ó¤ò»ØÄꤹ¤ë¤È¤³¤Î¼«Æ°Åª¤Ê½ÐÎϤ¬¹Ô¤ï¤ì¤Ê¤¯¤Ê¤ê¡¢
100 .B p
101 ¥³¥Þ¥ó¥É¤Ç½ÐÎϤ¹¤ë¤³¤È¤ò»ØÄꤵ¤ì¤¿¾ì¹ç¤Ë¸Â¤Ã¤Æ
102 \*(sd ¤Ï½ÐÎϤòÀ¸À®¤¹¤ë¡£
103 .TP
104 .B -e \fIscript\fP
105 .TP
106 .BI --expression= script
107 .\"O Add the commands in
108 .\"O .I script
109 .\"O to the set of commands to be run while processing the input.
110 .I script
111 ¤Î¥³¥Þ¥ó¥É¤ò¡¢ÆþÎϤνèÍýÃæ¤Ë¹Ô¤ï¤ì¤ë¥³¥Þ¥ó¥É¥»¥Ã¥È¤ËÄɲ乤롣
112 .TP
113 .B -f \fIscript-file\fP
114 .TP
115 .BI --file= script-file
116 .\"O Add the commands contained in the file
117 .\"O .I script-file
118 .\"O to the set of commands to be run while processing the input.
119 ¥Õ¥¡¥¤¥ë
120 .I script-file
121 ¤Ë´Þ¤Þ¤ì¤ë¥³¥Þ¥ó¥É¤ò¡¢ÆþÎϤνèÍýÃæ¤Ë¹Ô¤ï¤ì¤ë¥³¥Þ¥ó¥É¥»¥Ã¥È¤ËÄɲ乤롣
122 .PP
123 .\"O If no
124 .\"O .BR -e , -f , --expression ,
125 .\"O or
126 .\"O .B --file
127 .\"O options are given on the command-line,
128 .\"O then the first non-option argument on the command line is
129 .\"O taken to be the
130 .\"O .I script
131 .\"O to be executed.
132 .BR -e ", " -f ", " --expression ", " --file
133 ¤Ê¤É¤Î¥ª¥×¥·¥ç¥ó¤¬¥³¥Þ¥ó¥É¥é¥¤¥ó¤«¤éÁ´¤¯Í¿¤¨¤é¤ì¤Ê¤«¤Ã¤¿¾ì¹ç¤Ï¡¢
134 ¥³¥Þ¥ó¥É¥é¥¤¥ó¤Î°ú¤­¿ô¤Î¤¦¤Á¡¢¥ª¥×¥·¥ç¥ó¤Ç¤Ê¤¤ºÇ½é¤Î¤â¤Î¤¬
135 .I script
136 ¤È¤·¤Æ¼õ¤±¼è¤é¤ì¡¢¼Â¹Ô¤µ¤ì¤ë¡£
137 .PP
138 .\"O If any command-line parameters remain after processing the above,
139 .\"O these parameters are interpreted as the names of input files to
140 .\"O be processed.
141 .\"O A file name of
142 .\"O .B -
143 .\"O refers to the standard input stream.
144 .\"O The standard input will processed if no file names are specified.
145 °Ê¾å¤Î¥³¥Þ¥ó¥É¥é¥¤¥ó¥Ñ¥é¥á¡¼¥¿¤ò½èÍý¤·¤¿¤¢¤È¤Ë°ú¤­¿ô¤¬»Ä¤Ã¤¿¾ì¹ç¤Ï¡¢
146 ¤½¤ì¤é¤Ï½èÍýÂоݤȤʤëÆþÎÏ¥Õ¥¡¥¤¥ë¤Î¥Õ¥¡¥¤¥ë̾¤È²ò¼á¤µ¤ì¤ë¡£
147 .B -
148 ¤È¤¤¤¦¥Õ¥¡¥¤¥ë̾¤Ï¡¢É¸½àÆþÎÏ¥¹¥È¥ê¡¼¥à¤ò»²¾È¤¹¤ë¡£
149 ¥Õ¥¡¥¤¥ë̾¤¬Á´¤¯»ØÄꤵ¤ì¤Ê¤«¤Ã¤¿¾ì¹ç¤Ïɸ½àÆþÎϤò½èÍý¤¹¤ë¡£
150
151 .\"O .SH
152 .\"O Command Synopsis
153 .SH ¥³¥Þ¥ó¥É¤Îʸˡ
154 .\"O This is just a brief synopsis of \*(sd commands to serve as
155 .\"O a reminder to those who already know sed;
156 .\"O other documentation (such as the texinfo document)
157 .\"O must be consulted for fuller descriptions.
158 ¤³¤ì¤Ï \*(sd ¥³¥Þ¥ó¥É¤Î¤´¤¯´Êñ¤Êʸˡ¤Ç¡¢
159 ´û¤Ë sed ¤òÃΤäƤ¤¤ë¿Í¤ËÂФ¹¤ëÈ÷˺ϿÄøÅ٤Τâ¤Î¤Ç¤¢¤ë¡£
160 ´°Á´¤Êµ­½Ò¤òµá¤á¤ë¾ì¹ç¤Ï¾¤Îʸ½ñ (texinfo Ê¸½ñ¤Ê¤É) ¤Ë¤¢¤¿¤ë¤³¤È¡£
161 .\"O .SS
162 .\"O Zero-address ``commands''
163 .SS ¥¢¥É¥ì¥¹¤ò¼è¤é¤Ê¤¤¥³¥Þ¥ó¥É
164 .TP
165 .RI :\  label
166 .\"O Label for
167 .\"O .B b
168 .\"O and
169 .\"O .B t
170 .\"O commands.
171 .B b
172 ¥³¥Þ¥ó¥É¤È
173 .B t
174 ¥³¥Þ¥ó¥ÉÍѤΥé¥Ù¥ë¡£
175 .TP
176 .RI # comment
177 .\"O The comment extends until the next newline (or the end of a
178 .\"O .B -e
179 .\"O script fragment).
180 ¼¡¤Î²þ¹Ôʸ»ú¤Þ¤Ç (¤¢¤ë¤¤¤Ï
181 .B -e
182 ¥¹¥¯¥ê¥×¥È¥Õ¥é¥°¥á¥ó¥È¤ÎËöÈø¤Þ¤Ç) ¤ò¥³¥á¥ó¥È¤È¤·¤Æ¼è¤ê°·¤¦¡£
183 .TP
184 }
185 .\"O The closing bracket of a { } block.
186 { } ¥Ö¥í¥Ã¥¯¤ÎÊĤ¸³ç¸Ì¡£
187 .\"O .SS
188 .\"O Zero- or One- address commands
189 .SS ¥¢¥É¥ì¥¹¤ò 0 ¤Þ¤¿¤Ï 1 ¸Ä¤È¤ë¥³¥Þ¥ó¥É
190 .TP
191 =
192 .\"O Print the current line number.
193 ¸½ºß¤Î¹ÔÈÖ¹æ¤òɽ¼¨¤¹¤ë¡£
194 .TP
195 a \e
196 .TP
197 .I text
198 .\"O Append
199 .\"O .IR text ,
200 .\"O which has each embedded newline preceeded by a backslash.
201 .I text
202 ¤òÄɲ乤롣
203 .I text
204 ¤Ë²þ¹Ô¤ò´Þ¤á¤¿¤¤¾ì¹ç¤Ï¡¢¤½¤ÎÁ°¤Ë¥Ð¥Ã¥¯¥¹¥é¥Ã¥·¥å¤òÃÖ¤¯¡£
205 .TP
206 i \e
207 .TP
208 .I text
209 .\"O Insert
210 .\"O .IR text ,
211 .\"O which has each embedded newline preceeded by a backslash.
212 .I text
213 ¤òÁÞÆþ¤¹¤ë¡£
214 .I text
215 ¤Ë²þ¹Ô¤ò´Þ¤á¤¿¤¤¾ì¹ç¤Ï¡¢¤½¤ÎÁ°¤Ë¥Ð¥Ã¥¯¥¹¥é¥Ã¥·¥å¤òÃÖ¤¯¡£
216 .TP
217 q
218 .\"O Immediately quit the \*(sd script without processing
219 .\"O any more input,
220 .\"O except that if auto-print is not diabled
221 .\"O the current pattern space will be printed.
222 ¤³¤ì°Ê¾åÆþÎϤνèÍý¤ò¹Ô¤ï¤º¡¢¤¿¤À¤Á¤Ë \*(sd ¥¹¥¯¥ê¥×¥È¤Î½èÍý¤ò½ªÎ»¤¹¤ë¡£
223 ¤¿¤À¤· auto-print ¤¬ diable ¤µ¤ì¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢
224 ¥«¥ì¥ó¥È¤Î¥Ñ¥¿¡¼¥ó¥¹¥Ú¡¼¥¹¤¬½ÐÎϤµ¤ì¤ë¡£
225 .TP
226 .RI r\  filename
227 .\"O Append text read from
228 .\"O .IR filename .
229 ¥Æ¥­¥¹¥È¤ò
230 .I filename
231 ¤«¤éÆɤó¤ÇÄɲ乤롣
232 .\"O .SS
233 .\"O Commands which accept address ranges
234 .SS ¥¢¥É¥ì¥¹ÈϰϤò¤È¤ê¤¦¤ë¥³¥Þ¥ó¥É
235 .TP
236 {
237 .\"O Begin a block of commands (end with a }).
238 ¥³¥Þ¥ó¥É¥Ö¥í¥Ã¥¯¤Î³«»Ï (} ¤Ç½ªÎ»¤¹¤ë)¡£
239 .TP
240 .RI b\  label
241 .\"O Branch to
242 .\"O .IR label ;
243 .\"O if
244 .\"O .I label
245 .\"O is omitted, branch to end of script.
246 .I label
247 ¤Ëʬ´ô¤¹¤ë¡£
248 .I label
249 ¤¬¾Êά¤µ¤ì¤¿¾ì¹ç¤Ï¡¢¥¹¥¯¥ê¥×¥È¤ÎËöÈø¤Ëʬ´ô¤¹¤ë¡£
250 .TP
251 .RI t\  label
252 .\"O If a s/// has done a successful substitution since the
253 .\"O last input line was read and since the last t command,
254 .\"O then branch to
255 .\"O .IR label ;
256 .\"O if
257 .\"O .I label
258 .\"O is omitted, branch to end of script.
259 ºÇ¸å¤ËÆþÎϹԤ¬Æɤޤ졢ºÇ¸å¤Ë t ¥³¥Þ¥ó¥É¤¬¹Ô¤ï¤ì¤Æ°Ê¹ß¤Ë
260 s/// ¤¬À®¸ù¤·¤Æ¤¤¤ì¤Ð¡¢
261 .I label
262 ¤Ëʬ´ô¤¹¤ë¡£
263 .I label
264 ¤¬¾Êά¤µ¤ì¤¿¾ì¹ç¤Ï¡¢¥¹¥¯¥ê¥×¥È¤ÎËöÈø¤Ëʬ´ô¤¹¤ë¡£
265 .TP
266 c \e
267 .TP
268 .I text
269 .\"O Replace the selected lines with
270 .\"O .IR text ,
271 .\"O which has each embedded newline preceeded by a backslash.
272 ÁªÂò¤·¤¿¹Ô¤ò
273 .I text
274 ¤ÇÃÖ´¹¤¹¤ë¡£
275 .I text
276 ¤Ë²þ¹Ô¤ò´Þ¤á¤¿¤¤¾ì¹ç¤Ï¡¢¤½¤ÎÁ°¤Ë¥Ð¥Ã¥¯¥¹¥é¥Ã¥·¥å¤òÃÖ¤¯¡£
277 .TP
278 d
279 .\"O Delete pattern space.
280 .\"O Start next cycle.
281 ¥Ñ¥¿¡¼¥ó¥¹¥Ú¡¼¥¹¤òºï½ü¤¹¤ë¡£
282 ¼¡¤Î¥µ¥¤¥¯¥ë¤ò³«»Ï¤¹¤ë¡£
283 .TP
284 D
285 .\"O Delete up to the first embedded newline in the pattern space.
286 .\"O Start next cycle, but skip reading from the input
287 .\"O if there is still data in the pattern space.
288 ¥Ñ¥¿¡¼¥ó¥¹¥Ú¡¼¥¹¤ÎºÇ½é¤Î²þ¹Ô¤Þ¤Ç¤òºï½ü¤¹¤ë¡£
289 ¼¡¤Î¥µ¥¤¥¯¥ë¤ò³«»Ï¤¹¤ë¤¬¡¢
290 ¥Ñ¥¿¡¼¥ó¥¹¥Ú¡¼¥¹¤Ë¤Þ¤À¥Ç¡¼¥¿¤¬»Ä¤Ã¤Æ¤¤¤¿¤é¡¢
291 ÆþÎϤ«¤é¤ÎÆɤ߹þ¤ß¤ò¥¹¥­¥Ã¥×¤¹¤ë¡£
292 .TP
293 h H
294 .\"O Copy/append pattern space to hold space.
295 ¥Ñ¥¿¡¼¥ó¥¹¥Ú¡¼¥¹¤ò¥Û¡¼¥ë¥É¥¹¥Ú¡¼¥¹¤Ë¥³¥Ô¡¼/Äɲ乤롣
296 .TP
297 g G
298 .\"O Copy/append hold space to pattern space.
299 ¥Û¡¼¥ë¥É¥¹¥Ú¡¼¥¹¤ò¥Ñ¥¿¡¼¥ó¥¹¥Ú¡¼¥¹¤Ë¥³¥Ô¡¼/Äɲ乤롣
300 .TP
301 x
302 .\"O Exchange the contents of the hold and pattern spaces.
303 ¥Û¡¼¥ë¥É¥¹¥Ú¡¼¥¹¤È¥Ñ¥¿¡¼¥ó¥¹¥Ú¡¼¥¹¤ÎÆâÍƤò¸ò´¹¤¹¤ë¡£
304 .TP
305 l
306 .\"O List out the current line in a ``visually unambiguous'' form.
307 ¸½ºß¤Î¹Ô¤ò¡Ö»ë³ÐŪ¤Ëʶ¤ì¤Î¤Ê¤¤¡×·Á¼°¤Ç¥ê¥¹¥È¤¹¤ë¡£
308 .TP
309 n N
310 .\"O Read/append the next line of input into the pattern space.
311 ÆþÎϤμ¡¤Î¹Ô¤ò¥Ñ¥¿¡¼¥ó¥¹¥Ú¡¼¥¹¤ËÆɤ߹þ¤à/Äɲ乤롣
312 .TP
313 p
314 .\"O Print the current pattern space.
315 ¸½ºß¤Î¥Ñ¥¿¡¼¥ó¥¹¥Ú¡¼¥¹¤ò½ÐÎϤ¹¤ë¡£
316 .TP
317 P
318 .\"O Print up to the first embedded newline of the current pattern space.
319 ¸½ºß¤Î¥Ñ¥¿¡¼¥ó¥¹¥Ú¡¼¥¹¤ÎºÇ½é¤Î²þ¹Ô¤Þ¤Ç¤ò½ÐÎϤ¹¤ë¡£
320 .TP
321 .RI s/ regexp / replacement /
322 .\"O Attempt to match
323 .\"O .I regexp
324 .\"O against the pattern space.
325 ¥Ñ¥¿¡¼¥ó¥¹¥Ú¡¼¥¹¤ËÂФ·¤Æ
326 .I regexp
327 ¤Î¥Þ¥Ã¥Á¤ò»î¤ß¤ë¡£
328 .\"O If successful, replace that portion matched
329 .\"O with
330 .\"O .IR replacement .
331 ¥Þ¥Ã¥Á¤ËÀ®¸ù¤¹¤ë¤È¡¢¥Þ¥Ã¥Á¤·¤¿Éôʬ¤ò
332 .I replacement
333 ¤ËÃÖ´¹¤¹¤ë¡£
334 .\"O The
335 .\"O .I replacement
336 .\"O may contain the special character
337 .\"O .B &
338 .\"O to refer to that portion of the pattern space which matched,
339 .\"O and the special escapes \e1 through \e9 to refer to the
340 .\"O corresponding matching sub-expressions in the
341 .\"O .IR regexp .
342 .I replacement
343 ¤ÏÆüìʸ»ú¤Ç¤¢¤ë
344 .B &
345 ¤ò´Þ¤à¤³¤È¤¬¤Ç¤­¡¢¤³¤ì¤Ï¥Ñ¥¿¡¼¥ó¥¹¥Ú¡¼¥¹¤Î¥Þ¥Ã¥Á¤·¤¿Éôʬ¤ò»²¾È¤¹¤ë¡£
346 ¤Þ¤¿ \e1 ¤«¤é \e9 ¤Þ¤Ç¤ÎÆü쥨¥¹¥±¡¼¥×¤ò´Þ¤à¤³¤È¤â¤Ç¤­¡¢
347 ¤³¤ì¤Ï
348 .I regexp
349 ¤ÎÉûɽ¸½ (sub-expression) ¤Ë¥Þ¥Ã¥Á¤·¤¿Éôʬ¤ò¤½¤ì¤¾¤ì»²¾È¤¹¤ë¡£
350 .TP
351 .RI w\  filename
352 .\"O .I filename
353 .\"O Write the current pattern space to
354 .\"O .IR filename .
355 ¸½ºß¤Î¥Ñ¥¿¡¼¥ó¥¹¥Ú¡¼¥¹¤ò
356 .I filename
357 ¤Ë½ñ¤¯¡£
358 .TP
359 .RI y/ source / dest /
360 .\"O Transliterate the characters in the pattern space which appear in
361 .\"O .I source
362 .\"O to the corresponding character in
363 .\"O .IR dest .
364 ¥Ñ¥¿¡¼¥ó¥¹¥Ú¡¼¥¹¤Ë¤¢¤ëʸ»ú¤Î¤¦¤Á¡¢
365 .I source
366 ¤Ë¤¢¤ë¤â¤Î¤ò¡¢
367 .I dest
368 ¤ÎƱ¤¸°ÌÃ֤ˤ¢¤ëʸ»ú¤Ë¸ò´¹¤¹¤ë¡£
369 .\"O .SH
370 .\"O Addresses
371 .SH ¥¢¥É¥ì¥¹
372 .\"O \*(Sd commands can be given with no addresses, in which
373 .\"O case the command will be executed for all input lines;
374 .\"O with one address, in which case the command will only be executed
375 .\"O for input lines which match that address; or with two
376 .\"O addresses, in which case the command will be executed
377 .\"O for all input lines which match the inclusive range of
378 .\"O lines starting from the first address and continuing to
379 .\"O the second address.
380 \*(sd ¤Î¥³¥Þ¥ó¥É¤Ï¥¢¥É¥ì¥¹¤ò»ØÄꤻ¤º¤ËÍ¿¤¨¤ë¤³¤È¤â¤Ç¤­¡¢
381 ¤³¤Î¾ì¹ç¤½¤Î¥³¥Þ¥ó¥É¤Ï¤¹¤Ù¤Æ¤ÎÆþÎϹԤËÂФ·¤Æ¼Â¹Ô¤µ¤ì¤ë¡£
382 ¥¢¥É¥ì¥¹¤ò¤Ò¤È¤ÄÍ¿¤¨¤ë¤È¡¢
383 ¥³¥Þ¥ó¥É¤Ï¤½¤Î¥¢¥É¥ì¥¹¤Ë¥Þ¥Ã¥Á¤·¤¿ÆþÎϹԤËÂФ·¤Æ¤Î¤ß¼Â¹Ô¤µ¤ì¤ë¡£
384 2 ¤Ä¤Î¥¢¥É¥ì¥¹¤òÍ¿¤¨¤ë¤È¡¢ºÇ½é¤Î¥¢¥É¥ì¥¹¤Ë¥Þ¥Ã¥Á¤·¤¿¹Ô¤«¤é¡¢
385 2 ÈÖÌܤΥ¢¥É¥ì¥¹¤Ë¥Þ¥Ã¥Á¤·¤¿¹Ô¤Ë»ê¤ëÈÏ°Ï (ξ¥Þ¥Ã¥Á¹Ô¤ò´Þ¤à)
386 ¤Ë¤¢¤ë¤¹¤Ù¤Æ¤Î¹Ô¤ËÂФ·¤Æ¼Â¹Ô¤µ¤ì¤ë¡£
387 .\"O Three things to note about address ranges:
388 .\"O the syntax is
389 .\"O .IR addr1 , addr2
390 .\"O (i.e., the addresses are separated by a comma);
391 .\"O the line which
392 .\"O .I addr1
393 .\"O matched will always be accepted,
394 .\"O even if
395 .\"O .I addr2
396 .\"O selects an earlier line;
397 .\"O and if
398 .\"O .I addr2
399 .\"O is a
400 .\"O .IR regexp ,
401 .\"O it will not be tested against the line that
402 .\"O .I addr1
403 .\"O matched.
404 ¥¢¥É¥ì¥¹¤ÎÈÏ°Ï»ØÄê¤Ë¤Ä¤¤¤Æ¤Ï 3 ¤Ä¤Î¤³¤È¤òÃí°Õ¤·¤Æ¤ª¤¯¡£
405 ¤Þ¤º»ØÄêÊýË¡¤Ï
406 .IR addr1 , addr2
407 ¤Ç¤¢¤ë (¤Ä¤Þ¤ê¥¢¥É¥ì¥¹¤ò¥³¥ó¥Þ¤Ç¶èÀÚ¤ë)¡£
408 .I addr1
409 ¤Ë¥Þ¥Ã¥Á¤·¤¿¹Ô¤Ï¡¢¤¿¤È¤¨
410 .I addr2
411 ¤¬¤è¤êÁ°¤Î¹Ô¤Ë¥Þ¥Ã¥Á¤·¤¿¾ì¹ç¤Ç¤â¡¢¾ï¤Ë½èÍýÂоݤȤʤ롣
412 .I addr2
413 ¤¬
414 .I regexp
415 (Àµµ¬É½¸½) ¤Î¾ì¹ç¤Ë¤Ï¡¢
416 .I addr1
417 ¤Ë¥Þ¥Ã¥Á¤·¤¿¹Ô¤ËÂФ·¤Æ¤Ï
418 .I addr2
419 ¤Î¥Þ¥Ã¥Á¤Ï¹Ô¤ï¤ì¤Ê¤¤¡£
420 .PP
421 .\"O After the address (or address-range),
422 .\"O and before the command, a
423 .\"O .B !
424 .\"O may be inserted,
425 .\"O which specifies that the command shall only be
426 .\"O executed if the address (or address-range) does
427 .\"O .B not
428 .\"O match.
429 ¥¢¥É¥ì¥¹ (¤¢¤ë¤¤¤Ï¥¢¥É¥ì¥¹ÈÏ°Ï) ¤È¥³¥Þ¥ó¥É¤Î´Ö¤Ë¤Ï
430 .B !
431 ¤ò¶´¤à¤³¤È¤¬¤Ç¤­¤ë¡£¤³¤Î¾ì¹ç¤Ï¡¢¥¢¥É¥ì¥¹ (¤¢¤ë¤¤¤Ï¥¢¥É¥ì¥¹ÈÏ°Ï) ¤¬
432 \fB¥Þ¥Ã¥Á¤·¤Ê¤«¤Ã¤¿\fP¹Ô¤ËÂФ·¤Æ¤Î¤ß¥³¥Þ¥ó¥É¤¬¼Â¹Ô¤µ¤ì¤ë¡£
433 .PP
434 .\"O The following address types are supported:
435 °Ê²¼¤Î¥¢¥É¥ì¥¹¥¿¥¤¥×¤¬¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤ë¡£
436 .TP
437 .I number
438 .\"O Match only the specified line
439 .\"O .IR number .
440 .I number
441 ¤Ç»ØÄꤷ¤¿¹Ô¤À¤±¤Ë¥Þ¥Ã¥Á¤¹¤ë¡£
442 .TP
443 .IR first ~ step
444 .\"O Match every
445 .\"O .IR step 'th
446 .\"O line starting with line
447 .\"O .IR first .
448 .\"O For example, ``sed -n 1~2p'' will print all the odd-numbered lines in
449 .\"O the input stream, and the address 2~5 will match every fifth line,
450 .\"O starting with the second.
451 .\"O (This is a GNU extension.)
452 .I first
453 ¹Ô¤«¤é¤Ï¤¸¤Þ¤ë
454 .I step
455 ¹Ô¤ª¤­¤Î¹Ô¤Ë¥Þ¥Ã¥Á¤¹¤ë¡£Î㤨¤Ð ``sed -n 1~2p'' ¤Ï
456 ÆþÎϹԤΤ¦¤Á´ñ¿ô¹Ô¤òɽ¼¨¤·¡¢¥¢¥É¥ì¥¹¤ò 2~5 ¤Ë¤¹¤ë¤È¡¢
457 Âè 2 ¹Ô¤«¤é 5 ¹Ô¤ª¤­¤Ëɽ¼¨¤¹¤ë (¤³¤ì¤Ï GNU ¤Î³ÈÄ¥¤Ç¤¢¤ë)¡£
458 .TP
459 $
460 .\"O Match the last line.
461 ºÇ½ª¹Ô¤Ë¥Þ¥Ã¥Á¤¹¤ë¡£
462 .TP
463 .RI / regexp /
464 .\"O Match lines matching the regular expression
465 .\"O .IR regexp .
466 Àµµ¬É½¸½
467 .I regexp
468 ¤Ë¥Þ¥Ã¥Á¤·¤¿¹Ô¤Ë¥Þ¥Ã¥Á¤¹¤ë¡£
469 .TP
470 .BI \fR\e\fPc regexp c
471 .\"O Match lines matching the regular expression
472 .\"O .IR regexp .
473 .\"O The
474 .\"O .B c
475 .\"O may be any character.
476 Àµµ¬É½¸½
477 .I regexp
478 ¤Ë¥Þ¥Ã¥Á¤·¤¿¹Ô¤Ë¥Þ¥Ã¥Á¤¹¤ë¡£
479 ʸ»ú
480 .B c
481 ¤Ï²¿¤Ç¤â¤è¤¤¡£
482 .\"O .SH
483 .\"O Regular expressions
484 .SH Àµµ¬É½¸½
485 .\"O POSIX.2 BREs
486 .\"O .I should
487 .\"O be supported, but they aren't completely yet.
488 .\"O The
489 .\"O .B \en
490 .\"O sequence in a regular expression matches the newline character.
491 .\"O There are also some GNU extensions.
492 .\"O [XXX FIXME: more needs to be said.
493 .\"O At the very least, a reference to another document which
494 .\"O describes what is supported should be given.]
495 POSIX.2 BRE
496 ¤ò¥µ¥Ý¡¼¥È¤¹¤Ù¤­¤Ç¤¢¤ë¤¬¡¢¤Þ¤À´°Á´¤Ë¤Ï¥µ¥Ý¡¼¥È¤Ç¤­¤Æ¤¤¤Ê¤¤¡£
497 Àµµ¬É½¸½ÆâÉô¤Î
498 .B \en
499 ¥·¡¼¥±¥ó¥¹¤Ï²þ¹Ôʸ»ú¤Ë¥Þ¥Ã¥Á¤¹¤ë¡£
500 GNU ³ÈÄ¥¤â¸ºß¤¹¤ë¡£
501 [Í×½¤Àµ: ¤è¤ê¾ÜºÙ¤òµ­½Ò¤¹¤ëɬÍפ¬¤¢¤ë¡£
502 ¾¯¤Ê¤¯¤È¤â¡¢²¿¤¬¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤ë¤«¤ò½Ò¤Ù¤¿¡¢
503 ¾¤Îʸ½ñ¤Ø¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤¬É¬ÍפǤ¢¤ë]
504 .\"O .SH
505 .\"O Miscellaneous notes
506 .SH ¤½¤Î¾¤ÎÃí°Õ
507 .\"O This version of sed supports a
508 .\"O .RB \e <newline>
509 .\"O sequence in
510 .\"O all regular expressions, the
511 .\"O .I replacement
512 .\"O part of a substitute (s) command, and in the
513 .\"O .I source
514 .\"O and
515 .\"O .I dest
516 .\"O parts of a transliterate (y) command.
517 .\"O The \e is stripped, and the newline is kept.
518 ¤³¤Î¥Ð¡¼¥¸¥ç¥ó¤Î sed ¤Ï¡¢
519 ¤¢¤é¤æ¤ëÀµµ¬É½¸½¤ÎÆâÉô¡¦ÃÖ´¹¥³¥Þ¥ó¥É¤Î
520 .I replacement
521 ¤ÎÆâÉô¡¦Ê¸»ú¸ò´¹ (y) ¥³¥Þ¥ó¥É¤Î
522 .I source
523 ¤ª¤è¤Ó
524 .I dest
525 ¤ÎÆâÉô¤Î¤¤¤º¤ì¤Ë¤ª¤¤¤Æ¤â¡¢
526 .RB \e <newline>
527 ¤È¤¤¤¦¥·¡¼¥±¥ó¥¹¤¬»È¤¨¤ë¡£
528 .\"O .SH
529 .\"O SEE ALSO
530 .SH ´ØÏ¢¹àÌÜ
531 .BR awk (1),
532 .BR ed (1),
533 .BR expr (1),
534 .BR emacs (1),
535 .BR perl (1),
536 .BR tr (1),
537 .BR vi (1),
538 .BR regex (5)
539 .\"O [well, one
540 .\"O .I ought
541 .\"O to be written... XXX],
542 [¤¦¡¼¤ó¡¢½ñ¤«¤Ê¤¤¤È¥À¥á¤Ç¤¹¤Í¤¨]
543 ¡ÚÌõÃí: LDP ¤Ë¤Ï
544 .BR regex (7)
545 ¤¬¤¢¤ê¤Þ¤¹¡Û,
546 sed.info,
547 .\"O any of various books on \*(sd,
548 \*(sd ¤Ë´Ø¤¹¤ëÍÍ¡¹¤ÊËܤΤ¤¤º¤ì¤«,
549 .na
550 the \*(sd FAQ (http://www.wollery.demon.co.uk/sedtut10.txt,
551 http://www.ptug.org/sed/sedfaq.htm).
552 .\"O .SH
553 .\"O BUGS
554 .SH ¥Ð¥°
555 .PP
556 .\"O E-mail bug reports to
557 .\"O .BR bug-gnu-utils@gnu.org .
558 .\"O Be sure to include the word ``sed'' somewhere in the ``Subject:'' field.
559 ¥Ð¥°¥ì¥Ý¡¼¥È¤Ï
560 .B bug-gnu-utils@gnu.org
561 ¤Þ¤ÇÁ÷¤Ã¤Æ²¼¤µ¤¤¡£
562 ¡ÖSubject:¡×¥Õ¥£¡¼¥ë¥É¤Î¤É¤³¤«¤Ë
563 ¡Ösed¡×¤È¤¤¤¦Ã±¸ì¤òÆþ¤ì¤ë¤è¤¦¤Ë¤·¤ÆÍߤ·¤¤¡£