1 | \input texinfo @c -*-texinfo-*-
|
---|
2 | @c %**start of header
|
---|
3 | @setfilename grep.info
|
---|
4 | @settitle grep, print lines matching a pattern
|
---|
5 | @c %**end of header
|
---|
6 |
|
---|
7 | @c This file has the new style title page commands.
|
---|
8 | @c Run `makeinfo' rather than `texinfo-format-buffer'.
|
---|
9 |
|
---|
10 | @c smallbook
|
---|
11 |
|
---|
12 | @c tex
|
---|
13 | @c \overfullrule=0pt
|
---|
14 | @c end tex
|
---|
15 |
|
---|
16 | @include version.texi
|
---|
17 |
|
---|
18 | @c Combine indices.
|
---|
19 | @syncodeindex ky cp
|
---|
20 | @syncodeindex pg cp
|
---|
21 | @syncodeindex tp cp
|
---|
22 |
|
---|
23 | @defcodeindex op
|
---|
24 | @syncodeindex op fn
|
---|
25 | @syncodeindex vr fn
|
---|
26 |
|
---|
27 | @ifinfo
|
---|
28 | @direntry
|
---|
29 | * grep: (grep). print lines matching a pattern.
|
---|
30 | @end direntry
|
---|
31 | This file documents @command{grep}, a pattern matching engine.
|
---|
32 |
|
---|
33 |
|
---|
34 | Published by the Free Software Foundation,
|
---|
35 | 59 Temple Place - Suite 330
|
---|
36 | Boston, MA 02111-1307, USA
|
---|
37 |
|
---|
38 | @c man begin COPYRIGHT
|
---|
39 | Copyright @copyright{} 2000, 2001 Free Software Foundation, Inc.
|
---|
40 |
|
---|
41 | Permission is granted to make and distribute verbatim copies of
|
---|
42 | this manual provided the copyright notice and this permission notice
|
---|
43 | are preserved on all copies.
|
---|
44 |
|
---|
45 | @ignore
|
---|
46 | Permission is granted to process this file through TeX and print the
|
---|
47 | results, provided the printed document carries a copying permission
|
---|
48 | notice identical to this one except for the removal of this paragraph
|
---|
49 | (this paragraph not being relevant to the printed manual).
|
---|
50 |
|
---|
51 | @end ignore
|
---|
52 | Permission is granted to copy, distribute and/or modify this document
|
---|
53 | under the terms of the GNU Free Documentation License, Version 1.1 or
|
---|
54 | any later version published by the Free Software Foundation; with the
|
---|
55 | Invariant Sections being ``GNU General Public License'' and ``GNU Free
|
---|
56 | Documentation License'', with no Front-Cover Texts, and with no
|
---|
57 | Back-Cover Texts. A copy of the license is included in the section
|
---|
58 | entitled ``GNU Free Documentation License'' (@pxref{Copying}).
|
---|
59 | @c man end
|
---|
60 | @end ifinfo
|
---|
61 |
|
---|
62 | @setchapternewpage off
|
---|
63 |
|
---|
64 | @titlepage
|
---|
65 | @title grep, searching for a pattern
|
---|
66 | @subtitle version @value{VERSION}, @value{UPDATED}
|
---|
67 | @author Alain Magloire et al.
|
---|
68 |
|
---|
69 | @page
|
---|
70 | @vskip 0pt plus 1filll
|
---|
71 | Copyright @copyright{} 2000, 2001 Free Software Foundation, Inc.
|
---|
72 |
|
---|
73 | @sp 2
|
---|
74 | Published by the Free Software Foundation, @*
|
---|
75 | 59 Temple Place - Suite 330, @*
|
---|
76 | Boston, MA 02111-1307, USA
|
---|
77 |
|
---|
78 | Permission is granted to copy, distribute and/or modify this document
|
---|
79 | under the terms of the GNU Free Documentation License, Version 1.1 or
|
---|
80 | any later version published by the Free Software Foundation; with the
|
---|
81 | Invariant Sections being ``GNU General Public License'' and ``GNU Free
|
---|
82 | Documentation License'', with no Front-Cover Texts, and with no
|
---|
83 | Back-Cover Texts. A copy of the license is included in the section
|
---|
84 | entitled ``GNU Free Documentation License''.
|
---|
85 | @end titlepage
|
---|
86 |
|
---|
87 |
|
---|
88 | @ifnottex
|
---|
89 | @node Top
|
---|
90 | @top Grep
|
---|
91 |
|
---|
92 | @command{grep} searches for lines matching a pattern.
|
---|
93 |
|
---|
94 | This document was produced for version @value{VERSION} of @sc{gnu}
|
---|
95 | @command{grep}.
|
---|
96 | @end ifnottex
|
---|
97 |
|
---|
98 | @menu
|
---|
99 | * Introduction:: Introduction.
|
---|
100 | * Invoking:: Invoking @command{grep}; description of options.
|
---|
101 | * Diagnostics:: Exit status returned by @command{grep}.
|
---|
102 | * Grep Programs:: @command{grep} programs.
|
---|
103 | * Regular Expressions:: Regular Expressions.
|
---|
104 | * Usage:: Examples.
|
---|
105 | * Reporting Bugs:: Reporting Bugs.
|
---|
106 | * Copying:: License terms.
|
---|
107 | * Concept Index:: A menu with all the topics in this manual.
|
---|
108 | * Index:: A menu with all @command{grep} commands
|
---|
109 | and command-line options.
|
---|
110 | @end menu
|
---|
111 |
|
---|
112 |
|
---|
113 | @node Introduction, Invoking, Top, Top
|
---|
114 | @chapter Introduction
|
---|
115 |
|
---|
116 | @cindex Searching for a pattern.
|
---|
117 |
|
---|
118 | @command{grep} searches the input files
|
---|
119 | for lines containing a match to a given
|
---|
120 | pattern list. When it finds a match in a line, it copies the line to standard
|
---|
121 | output (by default), or does whatever other sort of output you have requested
|
---|
122 | with options.
|
---|
123 |
|
---|
124 | Though @command{grep} expects to do the matching on text,
|
---|
125 | it has no limits on input line length other than available memory,
|
---|
126 | and it can match arbitrary characters within a line.
|
---|
127 | If the final byte of an input file is not a newline,
|
---|
128 | @command{grep} silently supplies one.
|
---|
129 | Since newline is also a separator for the list of patterns, there
|
---|
130 | is no way to match newline characters in a text.
|
---|
131 |
|
---|
132 | @node Invoking
|
---|
133 | @chapter Invoking @command{grep}
|
---|
134 |
|
---|
135 | @command{grep} comes with a rich set of options from @sc{posix.2} and @sc{gnu}
|
---|
136 | extensions.
|
---|
137 |
|
---|
138 | @table @samp
|
---|
139 |
|
---|
140 | @item -c
|
---|
141 | @itemx --count
|
---|
142 | @opindex -c
|
---|
143 | @opindex --count
|
---|
144 | @cindex counting lines
|
---|
145 | Suppress normal output; instead print a count of matching
|
---|
146 | lines for each input file. With the @samp{-v}, @samp{--invert-match} option,
|
---|
147 | count non-matching lines.
|
---|
148 |
|
---|
149 | @item -e @var{pattern}
|
---|
150 | @itemx --regexp=@var{pattern}
|
---|
151 | @opindex -e
|
---|
152 | @opindex --regexp=@var{pattern}
|
---|
153 | @cindex pattern list
|
---|
154 | Use @var{pattern} as the pattern; useful to protect patterns
|
---|
155 | beginning with a @samp{-}.
|
---|
156 |
|
---|
157 | @item -f @var{file}
|
---|
158 | @itemx --file=@var{file}
|
---|
159 | @opindex -f
|
---|
160 | @opindex --file
|
---|
161 | @cindex pattern from file
|
---|
162 | Obtain patterns from @var{file}, one per line. The empty
|
---|
163 | file contains zero patterns, and therefore matches nothing.
|
---|
164 |
|
---|
165 | @item -i
|
---|
166 | @itemx --ignore-case
|
---|
167 | @opindex -i
|
---|
168 | @opindex --ignore-case
|
---|
169 | @cindex case insensitive search
|
---|
170 | Ignore case distinctions in both the pattern and the input files.
|
---|
171 |
|
---|
172 | @item -l
|
---|
173 | @itemx --files-with-matches
|
---|
174 | @opindex -l
|
---|
175 | @opindex --files-with-matches
|
---|
176 | @cindex names of matching files
|
---|
177 | Suppress normal output; instead print the name of each input
|
---|
178 | file from which output would normally have been printed.
|
---|
179 | The scanning of every file will stop on the first match.
|
---|
180 |
|
---|
181 | @item -n
|
---|
182 | @itemx --line-number
|
---|
183 | @opindex -n
|
---|
184 | @opindex --line-number
|
---|
185 | @cindex line numbering
|
---|
186 | Prefix each line of output with the line number within its input file.
|
---|
187 |
|
---|
188 | @item -o
|
---|
189 | @itemx --only-matching
|
---|
190 | @opindex -o
|
---|
191 | @opindex --only-matching
|
---|
192 | @cindex only matching
|
---|
193 | Print only the part of matching lines that actually matches @var{pattern}.
|
---|
194 |
|
---|
195 | @item -q
|
---|
196 | @itemx --quiet
|
---|
197 | @itemx --silent
|
---|
198 | @opindex -q
|
---|
199 | @opindex --quiet
|
---|
200 | @opindex --silent
|
---|
201 | @cindex quiet, silent
|
---|
202 | Quiet; do not write anything to standard output. Exit immediately with
|
---|
203 | zero status if any match is found, even if an error was detected. Also
|
---|
204 | see the @samp{-s} or @samp{--no-messages} option.
|
---|
205 |
|
---|
206 | @item -s
|
---|
207 | @itemx --no-messages
|
---|
208 | @opindex -s
|
---|
209 | @opindex --no-messages
|
---|
210 | @cindex suppress error messages
|
---|
211 | Suppress error messages about nonexistent or unreadable files.
|
---|
212 | Portability note: unlike @sc{gnu} @command{grep}, traditional
|
---|
213 | @command{grep} did not conform to @sc{posix.2}, because traditional
|
---|
214 | @command{grep} lacked a @samp{-q} option and its @samp{-s} option behaved
|
---|
215 | like @sc{gnu} @command{grep}'s @samp{-q} option. Shell scripts intended
|
---|
216 | to be portable to traditional @command{grep} should avoid both
|
---|
217 | @samp{-q} and @samp{-s} and should redirect
|
---|
218 | output to @file{/dev/null} instead.
|
---|
219 |
|
---|
220 | @item -v
|
---|
221 | @itemx --invert-match
|
---|
222 | @opindex -v
|
---|
223 | @opindex --invert-match
|
---|
224 | @cindex invert matching
|
---|
225 | @cindex print non-matching lines
|
---|
226 | Invert the sense of matching, to select non-matching lines.
|
---|
227 |
|
---|
228 | @item -x
|
---|
229 | @itemx --line-regexp
|
---|
230 | @opindex -x
|
---|
231 | @opindex --line-regexp
|
---|
232 | @cindex match the whole line
|
---|
233 | Select only those matches that exactly match the whole line.
|
---|
234 |
|
---|
235 | @end table
|
---|
236 |
|
---|
237 | @section @sc{gnu} Extensions
|
---|
238 |
|
---|
239 | @table @samp
|
---|
240 |
|
---|
241 | @item -A @var{num}
|
---|
242 | @itemx --after-context=@var{num}
|
---|
243 | @opindex -A
|
---|
244 | @opindex --after-context
|
---|
245 | @cindex after context
|
---|
246 | @cindex context lines, after match
|
---|
247 | Print @var{num} lines of trailing context after matching lines.
|
---|
248 |
|
---|
249 | @item -B @var{num}
|
---|
250 | @itemx --before-context=@var{num}
|
---|
251 | @opindex -B
|
---|
252 | @opindex --before-context
|
---|
253 | @cindex before context
|
---|
254 | @cindex context lines, before match
|
---|
255 | Print @var{num} lines of leading context before matching lines.
|
---|
256 |
|
---|
257 | @item -C @var{num}
|
---|
258 | @itemx --context=@var{num}
|
---|
259 | @opindex -C
|
---|
260 | @opindex --context
|
---|
261 | @cindex context
|
---|
262 | Print @var{num} lines of output context.
|
---|
263 |
|
---|
264 | @item --colour[=@var{WHEN}]
|
---|
265 | @itemx --color[=@var{WHEN}]
|
---|
266 | @opindex --colour
|
---|
267 | @cindex highlight, color, colour
|
---|
268 | The matching string is surrounded by the marker specify in @var{GREP_COLOR}.
|
---|
269 | @var{WHEN} may be `never', `always', or `auto'.
|
---|
270 |
|
---|
271 | @item -@var{num}
|
---|
272 | @opindex -NUM
|
---|
273 | Same as @samp{--context=@var{num}} lines of leading and trailing
|
---|
274 | context. However, grep will never print any given line more than once.
|
---|
275 |
|
---|
276 |
|
---|
277 | @item -V
|
---|
278 | @itemx --version
|
---|
279 | @opindex -V
|
---|
280 | @opindex --version
|
---|
281 | @cindex Version, printing
|
---|
282 | Print the version number of @command{grep} to the standard output stream.
|
---|
283 | This version number should be included in all bug reports.
|
---|
284 |
|
---|
285 | @item --help
|
---|
286 | @opindex --help
|
---|
287 | @cindex Usage summary, printing
|
---|
288 | Print a usage message briefly summarizing these command-line options
|
---|
289 | and the bug-reporting address, then exit.
|
---|
290 |
|
---|
291 | @itemx --binary-files=@var{type}
|
---|
292 | @opindex --binary-files
|
---|
293 | @cindex binary files
|
---|
294 | If the first few bytes of a file indicate that the file contains binary
|
---|
295 | data, assume that the file is of type @var{type}. By default,
|
---|
296 | @var{type} is @samp{binary}, and @command{grep} normally outputs either
|
---|
297 | a one-line message saying that a binary file matches, or no message if
|
---|
298 | there is no match. If @var{type} is @samp{without-match},
|
---|
299 | @command{grep} assumes that a binary file does not match;
|
---|
300 | this is equivalent to the @samp{-I} option. If @var{type}
|
---|
301 | is @samp{text}, @command{grep} processes a binary file as if it were
|
---|
302 | text; this is equivalent to the @samp{-a} option.
|
---|
303 | @emph{Warning:} @samp{--binary-files=text} might output binary garbage,
|
---|
304 | which can have nasty side effects if the output is a terminal and if the
|
---|
305 | terminal driver interprets some of it as commands.
|
---|
306 |
|
---|
307 | @item -b
|
---|
308 | @itemx --byte-offset
|
---|
309 | @opindex -b
|
---|
310 | @opindex --byte-offset
|
---|
311 | @cindex byte offset
|
---|
312 | Print the byte offset within the input file before each line of output.
|
---|
313 | When @command{grep} runs on @sc{ms-dos} or MS-Windows, the printed
|
---|
314 | byte offsets
|
---|
315 | depend on whether the @samp{-u} (@samp{--unix-byte-offsets}) option is
|
---|
316 | used; see below.
|
---|
317 |
|
---|
318 | @item -D @var{action}
|
---|
319 | @itemx --devices=@var{action}
|
---|
320 | @opindex -D
|
---|
321 | @opindex --devices
|
---|
322 | @cindex device search
|
---|
323 | If an input file is a device, FIFO or socket, use @var{action} to process it.
|
---|
324 | By default, @var{action} is @samp{read}, which means that devices are
|
---|
325 | read just as if they were ordinary files.
|
---|
326 | If @var{action} is @samp{skip}, devices, FIFOs and sockets are silently
|
---|
327 | skipped.
|
---|
328 |
|
---|
329 | @item -d @var{action}
|
---|
330 | @itemx --directories=@var{action}
|
---|
331 | @opindex -d
|
---|
332 | @opindex --directories
|
---|
333 | @cindex directory search
|
---|
334 | If an input file is a directory, use @var{action} to process it.
|
---|
335 | By default, @var{action} is @samp{read}, which means that directories are
|
---|
336 | read just as if they were ordinary files (some operating systems
|
---|
337 | and filesystems disallow this, and will cause @command{grep} to print error
|
---|
338 | messages for every directory or silently skip them). If @var{action} is
|
---|
339 | @samp{skip}, directories are silently skipped. If @var{action} is
|
---|
340 | @samp{recurse}, @command{grep} reads all files under each directory,
|
---|
341 | recursively; this is equivalent to the @samp{-r} option.
|
---|
342 |
|
---|
343 | @item -H
|
---|
344 | @itemx --with-filename
|
---|
345 | @opindex -H
|
---|
346 | @opindex --With-filename
|
---|
347 | @cindex with filename prefix
|
---|
348 | Print the filename for each match.
|
---|
349 |
|
---|
350 | @item -h
|
---|
351 | @itemx --no-filename
|
---|
352 | @opindex -h
|
---|
353 | @opindex --no-filename
|
---|
354 | @cindex no filename prefix
|
---|
355 | Suppress the prefixing of filenames on output when multiple files are searched.
|
---|
356 |
|
---|
357 | @item --line-buffered
|
---|
358 | @opindex --line-buffered
|
---|
359 | @cindex line buffering
|
---|
360 | Set the line buffering policy, this can be a performance penality.
|
---|
361 |
|
---|
362 | @item --label=@var{LABEL}
|
---|
363 | @opindex --label
|
---|
364 | @cindex changing name of standard input
|
---|
365 | Displays input actually coming from standard input as input coming from file
|
---|
366 | @var{LABEL}. This is especially useful for tools like zgrep, e.g.
|
---|
367 | @command{gzip -cd foo.gz |grep --label=foo something}
|
---|
368 |
|
---|
369 | @item -L
|
---|
370 | @itemx --files-without-match
|
---|
371 | @opindex -L
|
---|
372 | @opindex --files-without-match
|
---|
373 | @cindex files which don't match
|
---|
374 | Suppress normal output; instead print the name of each input
|
---|
375 | file from which no output would normally have been printed.
|
---|
376 | The scanning of every file will stop on the first match.
|
---|
377 |
|
---|
378 | @item -a
|
---|
379 | @itemx --text
|
---|
380 | @opindex -a
|
---|
381 | @opindex --text
|
---|
382 | @cindex suppress binary data
|
---|
383 | @cindex binary files
|
---|
384 | Process a binary file as if it were text; this is equivalent to the
|
---|
385 | @samp{--binary-files=text} option.
|
---|
386 |
|
---|
387 | @item -I
|
---|
388 | Process a binary file as if it did not contain matching data; this is
|
---|
389 | equivalent to the @samp{--binary-files=without-match} option.
|
---|
390 |
|
---|
391 | @item -w
|
---|
392 | @itemx --word-regexp
|
---|
393 | @opindex -w
|
---|
394 | @opindex --word-regexp
|
---|
395 | @cindex matching whole words
|
---|
396 | Select only those lines containing matches that form
|
---|
397 | whole words. The test is that the matching substring
|
---|
398 | must either be at the beginning of the line, or preceded
|
---|
399 | by a non-word constituent character. Similarly,
|
---|
400 | it must be either at the end of the line or followed by
|
---|
401 | a non-word constituent character. Word-constituent
|
---|
402 | characters are letters, digits, and the underscore.
|
---|
403 |
|
---|
404 | @item -r
|
---|
405 | @itemx -R
|
---|
406 | @itemx --recursive
|
---|
407 | @opindex -r
|
---|
408 | @opindex --recursive
|
---|
409 | @cindex recursive search
|
---|
410 | @cindex searching directory trees
|
---|
411 | For each directory mentioned in the command line, read and process all
|
---|
412 | files in that directory, recursively. This is the same as the
|
---|
413 | @samp{--directories=recurse} option.
|
---|
414 |
|
---|
415 | @item --include=@var{file_pattern}
|
---|
416 | @opindex --include
|
---|
417 | @cindex include files
|
---|
418 | @cindex searching directory trees
|
---|
419 | When processing directories recursively, only files matching @var{file_pattern}
|
---|
420 | will be search.
|
---|
421 |
|
---|
422 | @item --exclude=@var{file_pattern}
|
---|
423 | @opindex --exclude
|
---|
424 | @cindex exclude files
|
---|
425 | @cindex searching directory trees
|
---|
426 | When processing directories recursively, skip files matching @var{file_pattern}.
|
---|
427 |
|
---|
428 | @item -m @var{num}
|
---|
429 | @itemx --max-count=@var{num}
|
---|
430 | @opindex -m
|
---|
431 | @opindex --max-count
|
---|
432 | @cindex max-count
|
---|
433 | Stop reading a file after @var{num} matching lines. If the input is
|
---|
434 | standard input from a regular file, and @var{num} matching lines are
|
---|
435 | output, @command{grep} ensures that the standard input is positioned to
|
---|
436 | just after the last matching line before exiting, regardless of the
|
---|
437 | presence of trailing context lines. This enables a calling process
|
---|
438 | to resume a search. For example, the following shell script makes use
|
---|
439 | of it:
|
---|
440 |
|
---|
441 | @example
|
---|
442 | while grep -m 1 PATTERN
|
---|
443 | do
|
---|
444 | echo xxxx
|
---|
445 | done < FILE
|
---|
446 | @end example
|
---|
447 |
|
---|
448 | But the following probably will not work because a pipe is not a regular
|
---|
449 | file:
|
---|
450 |
|
---|
451 | @example
|
---|
452 | # This probably will not work.
|
---|
453 | cat FILE |
|
---|
454 | while grep -m 1 PATTERN
|
---|
455 | do
|
---|
456 | echo xxxx
|
---|
457 | done
|
---|
458 | @end example
|
---|
459 |
|
---|
460 | When @command{grep} stops after NUM matching lines, it outputs
|
---|
461 | any trailing context lines. Since context does not include matching
|
---|
462 | lines, @command{grep} will stop when it encounters another matching line.
|
---|
463 | When the @samp{-c} or @samp{--count} option is also used,
|
---|
464 | @command{grep} does not output a count greater than @var{num}.
|
---|
465 | When the @samp{-v} or @samp{--invert-match} option is
|
---|
466 | also used, @command{grep} stops after outputting @var{num}
|
---|
467 | non-matching lines.
|
---|
468 |
|
---|
469 | @item -y
|
---|
470 | @opindex -y
|
---|
471 | @cindex case insensitive search, obsolete option
|
---|
472 | Obsolete synonym for @samp{-i}.
|
---|
473 |
|
---|
474 | @item -U
|
---|
475 | @itemx --binary
|
---|
476 | @opindex -U
|
---|
477 | @opindex --binary
|
---|
478 | @cindex DOS/Windows binary files
|
---|
479 | @cindex binary files, DOS/Windows
|
---|
480 | Treat the file(s) as binary. By default, under @sc{ms-dos}
|
---|
481 | and MS-Windows, @command{grep} guesses the file type by looking
|
---|
482 | at the contents of the first 32kB read from the file.
|
---|
483 | If @command{grep} decides the file is a text file, it strips the
|
---|
484 | @code{CR} characters from the original file contents (to make
|
---|
485 | regular expressions with @code{^} and @code{$} work correctly).
|
---|
486 | Specifying @samp{-U} overrules this guesswork, causing all
|
---|
487 | files to be read and passed to the matching mechanism
|
---|
488 | verbatim; if the file is a text file with @code{CR/LF} pairs
|
---|
489 | at the end of each line, this will cause some regular
|
---|
490 | expressions to fail. This option has no effect on platforms other than
|
---|
491 | @sc{ms-dos} and MS-Windows.
|
---|
492 |
|
---|
493 | @item -u
|
---|
494 | @itemx --unix-byte-offsets
|
---|
495 | @opindex -u
|
---|
496 | @opindex --unix-byte-offsets
|
---|
497 | @cindex DOS byte offsets
|
---|
498 | @cindex byte offsets, on DOS/Windows
|
---|
499 | Report Unix-style byte offsets. This switch causes
|
---|
500 | @command{grep} to report byte offsets as if the file were Unix style
|
---|
501 | text file, i.e., the byte offsets ignore the @code{CR} characters which were
|
---|
502 | stripped. This will produce results identical to running @command{grep} on
|
---|
503 | a Unix machine. This option has no effect unless @samp{-b}
|
---|
504 | option is also used; it has no effect on platforms other than @sc{ms-dos} and
|
---|
505 | MS-Windows.
|
---|
506 |
|
---|
507 | @item --mmap
|
---|
508 | @opindex --mmap
|
---|
509 | @cindex memory mapped input
|
---|
510 | If possible, use the @code{mmap} system call to read input, instead of
|
---|
511 | the default @code{read} system call. In some situations, @samp{--mmap}
|
---|
512 | yields better performance. However, @samp{--mmap} can cause undefined
|
---|
513 | behavior (including core dumps) if an input file shrinks while
|
---|
514 | @command{grep} is operating, or if an I/O error occurs.
|
---|
515 |
|
---|
516 | @item -Z
|
---|
517 | @itemx --null
|
---|
518 | @opindex -Z
|
---|
519 | @opindex --null
|
---|
520 | @cindex zero-terminated file names
|
---|
521 | Output a zero byte (the @sc{ascii} @code{NUL} character) instead of the
|
---|
522 | character that normally follows a file name. For example, @samp{grep
|
---|
523 | -lZ} outputs a zero byte after each file name instead of the usual
|
---|
524 | newline. This option makes the output unambiguous, even in the presence
|
---|
525 | of file names containing unusual characters like newlines. This option
|
---|
526 | can be used with commands like @samp{find -print0}, @samp{perl -0},
|
---|
527 | @samp{sort -z}, and @samp{xargs -0} to process arbitrary file names,
|
---|
528 | even those that contain newline characters.
|
---|
529 |
|
---|
530 | @item -z
|
---|
531 | @itemx --null-data
|
---|
532 | @opindex -z
|
---|
533 | @opindex --null-data
|
---|
534 | @cindex zero-terminated lines
|
---|
535 | Treat the input as a set of lines, each terminated by a zero byte (the
|
---|
536 | @sc{ascii} @code{NUL} character) instead of a newline. Like the @samp{-Z}
|
---|
537 | or @samp{--null} option, this option can be used with commands like
|
---|
538 | @samp{sort -z} to process arbitrary file names.
|
---|
539 |
|
---|
540 | @end table
|
---|
541 |
|
---|
542 | Several additional options control which variant of the @command{grep}
|
---|
543 | matching engine is used. @xref{Grep Programs}.
|
---|
544 |
|
---|
545 | @section Environment Variables
|
---|
546 |
|
---|
547 | Grep's behavior is affected by the following environment variables.
|
---|
548 |
|
---|
549 | A locale @code{LC_@var{foo}} is specified by examining the three
|
---|
550 | environment variables @env{LC_ALL}, @env{LC_@var{foo}}, and @env{LANG},
|
---|
551 | in that order. The first of these variables that is set specifies the
|
---|
552 | locale. For example, if @env{LC_ALL} is not set, but @env{LC_MESSAGES}
|
---|
553 | is set to @samp{pt_BR}, then Brazilian Portuguese is used for the
|
---|
554 | @code{LC_MESSAGES} locale. The C locale is used if none of these
|
---|
555 | environment variables are set, or if the locale catalog is not
|
---|
556 | installed, or if @command{grep} was not compiled with national language
|
---|
557 | support (@sc{nls}).
|
---|
558 |
|
---|
559 | @cindex environment variables
|
---|
560 |
|
---|
561 | @table @env
|
---|
562 |
|
---|
563 | @item GREP_OPTIONS
|
---|
564 | @vindex GREP_OPTIONS
|
---|
565 | @cindex default options environment variable
|
---|
566 | This variable specifies default options to be placed in front of any
|
---|
567 | explicit options. For example, if @code{GREP_OPTIONS} is
|
---|
568 | @samp{--binary-files=without-match --directories=skip}, @command{grep}
|
---|
569 | behaves as if the two options @samp{--binary-files=without-match} and
|
---|
570 | @samp{--directories=skip} had been specified before
|
---|
571 | any explicit options. Option specifications are separated by
|
---|
572 | whitespace. A backslash escapes the next character, so it can be used to
|
---|
573 | specify an option containing whitespace or a backslash.
|
---|
574 |
|
---|
575 | @item GREP_COLOR
|
---|
576 | @vindex GREP_COLOR
|
---|
577 | @cindex highlight markers
|
---|
578 | This variable specifies the surrounding markers use to highlight the matching
|
---|
579 | text. The default is control ascii red.
|
---|
580 |
|
---|
581 | @item LC_ALL
|
---|
582 | @itemx LC_COLLATE
|
---|
583 | @itemx LANG
|
---|
584 | @vindex LC_ALL
|
---|
585 | @vindex LC_COLLATE
|
---|
586 | @vindex LANG
|
---|
587 | @cindex character type
|
---|
588 | @cindex national language support
|
---|
589 | @cindex NLS
|
---|
590 | These variables specify the @code{LC_COLLATE} locale, which determines
|
---|
591 | the collating sequence used to interpret range expressions like
|
---|
592 | @samp{[a-z]}.
|
---|
593 |
|
---|
594 | @item LC_ALL
|
---|
595 | @itemx LC_CTYPE
|
---|
596 | @itemx LANG
|
---|
597 | @vindex LC_ALL
|
---|
598 | @vindex LC_CTYPE
|
---|
599 | @vindex LANG
|
---|
600 | @cindex character type
|
---|
601 | @cindex national language support
|
---|
602 | @cindex NLS
|
---|
603 | These variables specify the @code{LC_CTYPE} locale, which determines the
|
---|
604 | type of characters, e.g., which characters are whitespace.
|
---|
605 |
|
---|
606 | @item LC_ALL
|
---|
607 | @itemx LC_MESSAGES
|
---|
608 | @itemx LANG
|
---|
609 | @vindex LC_ALL
|
---|
610 | @vindex LC_MESSAGES
|
---|
611 | @vindex LANG
|
---|
612 | @cindex language of messages
|
---|
613 | @cindex message language
|
---|
614 | @cindex national language support
|
---|
615 | @cindex NLS
|
---|
616 | @cindex translation of message language
|
---|
617 | These variables specify the @code{LC_MESSAGES} locale, which determines
|
---|
618 | the language that @command{grep} uses for messages. The default C
|
---|
619 | locale uses American English messages.
|
---|
620 |
|
---|
621 | @item POSIXLY_CORRECT
|
---|
622 | @vindex POSIXLY_CORRECT
|
---|
623 | If set, @command{grep} behaves as @sc{posix.2} requires; otherwise,
|
---|
624 | @command{grep} behaves more like other @sc{gnu} programs. @sc{posix.2}
|
---|
625 | requires that options that
|
---|
626 | follow file names must be treated as file names; by default, such
|
---|
627 | options are permuted to the front of the operand list and are treated as
|
---|
628 | options. Also, @sc{posix.2} requires that unrecognized options be
|
---|
629 | diagnosed as
|
---|
630 | ``illegal'', but since they are not really against the law the default
|
---|
631 | is to diagnose them as ``invalid''. @code{POSIXLY_CORRECT} also
|
---|
632 | disables @code{_@var{N}_GNU_nonoption_argv_flags_}, described below.
|
---|
633 |
|
---|
634 | @item _@var{N}_GNU_nonoption_argv_flags_
|
---|
635 | @vindex _@var{N}_GNU_nonoption_argv_flags_
|
---|
636 | (Here @code{@var{N}} is @command{grep}'s numeric process ID.) If the
|
---|
637 | @var{i}th character of this environment variable's value is @samp{1}, do
|
---|
638 | not consider the @var{i}th operand of @command{grep} to be an option, even if
|
---|
639 | it appears to be one. A shell can put this variable in the environment
|
---|
640 | for each command it runs, specifying which operands are the results of
|
---|
641 | file name wildcard expansion and therefore should not be treated as
|
---|
642 | options. This behavior is available only with the @sc{gnu} C library, and
|
---|
643 | only when @code{POSIXLY_CORRECT} is not set.
|
---|
644 |
|
---|
645 | @end table
|
---|
646 |
|
---|
647 | @node Diagnostics
|
---|
648 | @chapter Diagnostics
|
---|
649 |
|
---|
650 | Normally, exit status is 0 if selected lines are found and 1 otherwise.
|
---|
651 | But the exit status is 2 if an error occurred, unless the @option{-q} or
|
---|
652 | @option{--quiet} or @option{--silent} option is used and a selected line
|
---|
653 | is found.
|
---|
654 |
|
---|
655 | @node Grep Programs
|
---|
656 | @chapter @command{grep} programs
|
---|
657 |
|
---|
658 | @command{grep} searches the named input files (or standard input if no
|
---|
659 | files are named, or the file name @file{-} is given) for lines containing
|
---|
660 | a match to the given pattern. By default, @command{grep} prints the
|
---|
661 | matching lines. There are four major variants of @command{grep},
|
---|
662 | controlled by the following options.
|
---|
663 |
|
---|
664 | @table @samp
|
---|
665 |
|
---|
666 | @item -G
|
---|
667 | @itemx --basic-regexp
|
---|
668 | @opindex -G
|
---|
669 | @opindex --basic-regexp
|
---|
670 | @cindex matching basic regular expressions
|
---|
671 | Interpret the pattern as a basic regular expression. This is the default.
|
---|
672 |
|
---|
673 | @item -E
|
---|
674 | @itemx --extended-regexp
|
---|
675 | @opindex -E
|
---|
676 | @opindex --extended-regexp
|
---|
677 | @cindex matching extended regular expressions
|
---|
678 | Interpret the pattern as an extended regular expression.
|
---|
679 |
|
---|
680 | @item -F
|
---|
681 | @itemx --fixed-strings
|
---|
682 | @opindex -F
|
---|
683 | @opindex --fixed-strings
|
---|
684 | @cindex matching fixed strings
|
---|
685 | Interpret the pattern as a list of fixed strings, separated
|
---|
686 | by newlines, any of which is to be matched.
|
---|
687 |
|
---|
688 | @item -P
|
---|
689 | @itemx --perl-regexp
|
---|
690 | @opindex -P
|
---|
691 | @opindex --perl-regexp
|
---|
692 | @cindex matching Perl regular expressions
|
---|
693 | Interpret the pattern as a Perl regular expression.
|
---|
694 |
|
---|
695 | @end table
|
---|
696 |
|
---|
697 | In addition, two variant programs @sc{egrep} and @sc{fgrep} are available.
|
---|
698 | @sc{egrep} is the same as @samp{grep -E}. @sc{fgrep} is the
|
---|
699 | same as @samp{grep -F}.
|
---|
700 |
|
---|
701 | @node Regular Expressions
|
---|
702 | @chapter Regular Expressions
|
---|
703 | @cindex regular expressions
|
---|
704 |
|
---|
705 | A @dfn{regular expression} is a pattern that describes a set of strings.
|
---|
706 | Regular expressions are constructed analogously to arithmetic expressions,
|
---|
707 | by using various operators to combine smaller expressions.
|
---|
708 | @command{grep} understands two different versions of regular expression
|
---|
709 | syntax: ``basic''(BRE) and ``extended''(ERE). In @sc{gnu} @command{grep},
|
---|
710 | there is no difference in available functionality using either syntax.
|
---|
711 | In other implementations, basic regular expressions are less powerful.
|
---|
712 | The following description applies to extended regular expressions;
|
---|
713 | differences for basic regular expressions are summarized afterwards.
|
---|
714 |
|
---|
715 | The fundamental building blocks are the regular expressions that match
|
---|
716 | a single character. Most characters, including all letters and digits,
|
---|
717 | are regular expressions that match themselves. Any metacharacter
|
---|
718 | with special meaning may be quoted by preceding it with a backslash.
|
---|
719 |
|
---|
720 | A regular expression may be followed by one of several
|
---|
721 | repetition operators:
|
---|
722 |
|
---|
723 | @table @samp
|
---|
724 |
|
---|
725 | @item .
|
---|
726 | @opindex .
|
---|
727 | @cindex dot
|
---|
728 | @cindex period
|
---|
729 | The period @samp{.} matches any single character.
|
---|
730 |
|
---|
731 | @item ?
|
---|
732 | @opindex ?
|
---|
733 | @cindex question mark
|
---|
734 | @cindex match sub-expression at most once
|
---|
735 | The preceding item is optional and will be matched at most once.
|
---|
736 |
|
---|
737 | @item *
|
---|
738 | @opindex *
|
---|
739 | @cindex asterisk
|
---|
740 | @cindex match sub-expression zero or more times
|
---|
741 | The preceding item will be matched zero or more times.
|
---|
742 |
|
---|
743 | @item +
|
---|
744 | @opindex +
|
---|
745 | @cindex plus sign
|
---|
746 | The preceding item will be matched one or more times.
|
---|
747 |
|
---|
748 | @item @{@var{n}@}
|
---|
749 | @opindex @{n@}
|
---|
750 | @cindex braces, one argument
|
---|
751 | @cindex match sub-expression n times
|
---|
752 | The preceding item is matched exactly @var{n} times.
|
---|
753 |
|
---|
754 | @item @{@var{n},@}
|
---|
755 | @opindex @{n,@}
|
---|
756 | @cindex braces, second argument omitted
|
---|
757 | @cindex match sub-expression n or more times
|
---|
758 | The preceding item is matched n or more times.
|
---|
759 |
|
---|
760 | @item @{@var{n},@var{m}@}
|
---|
761 | @opindex @{n,m@}
|
---|
762 | @cindex braces, two arguments
|
---|
763 | The preceding item is matched at least @var{n} times, but not more than
|
---|
764 | @var{m} times.
|
---|
765 |
|
---|
766 | @end table
|
---|
767 |
|
---|
768 | Two regular expressions may be concatenated; the resulting regular
|
---|
769 | expression matches any string formed by concatenating two substrings
|
---|
770 | that respectively match the concatenated subexpressions.
|
---|
771 |
|
---|
772 | Two regular expressions may be joined by the infix operator @samp{|}; the
|
---|
773 | resulting regular expression matches any string matching either subexpression.
|
---|
774 |
|
---|
775 | Repetition takes precedence over concatenation, which in turn
|
---|
776 | takes precedence over alternation. A whole subexpression may be
|
---|
777 | enclosed in parentheses to override these precedence rules.
|
---|
778 |
|
---|
779 | @section Character Class
|
---|
780 |
|
---|
781 | @cindex bracket expression
|
---|
782 | @cindex character class
|
---|
783 | A @dfn{bracket expression} is a list of characters enclosed by @samp{[} and
|
---|
784 | @samp{]}. It matches any single character in that list; if the first
|
---|
785 | character of the list is the caret @samp{^}, then it matches any character
|
---|
786 | @strong{not} in the list. For example, the regular expression
|
---|
787 | @samp{[0123456789]} matches any single digit.
|
---|
788 |
|
---|
789 | @cindex range expression
|
---|
790 | Within a bracket expression, a @dfn{range expression} consists of two
|
---|
791 | characters separated by a hyphen. It matches any single character that
|
---|
792 | sorts between the two characters, inclusive, using the locale's
|
---|
793 | collating sequence and character set. For example, in the default C
|
---|
794 | locale, @samp{[a-d]} is equivalent to @samp{[abcd]}. Many locales sort
|
---|
795 | characters in dictionary order, and in these locales @samp{[a-d]} is
|
---|
796 | typically not equivalent to @samp{[abcd]}; it might be equivalent to
|
---|
797 | @samp{[aBbCcDd]}, for example. To obtain the traditional interpretation
|
---|
798 | of bracket expressions, you can use the C locale by setting the
|
---|
799 | @env{LC_ALL} environment variable to the value @samp{C}.
|
---|
800 |
|
---|
801 | Finally, certain named classes of characters are predefined within
|
---|
802 | bracket expressions, as follows.
|
---|
803 | Their interpretation depends on the @code{LC_CTYPE} locale; the
|
---|
804 | interpretation below is that of the C locale, which is the default
|
---|
805 | if no @code{LC_CTYPE} locale is specified.
|
---|
806 |
|
---|
807 | @cindex classes of characters
|
---|
808 | @cindex character classes
|
---|
809 | @table @samp
|
---|
810 |
|
---|
811 | @item [:alnum:]
|
---|
812 | @opindex alnum
|
---|
813 | @cindex alphanumeric characters
|
---|
814 | Alphanumeric characters:
|
---|
815 | @samp{[:alpha:]} and @samp{[:digit:]}.
|
---|
816 |
|
---|
817 | @item [:alpha:]
|
---|
818 | @opindex alpha
|
---|
819 | @cindex alphabetic characters
|
---|
820 | Alphabetic characters:
|
---|
821 | @samp{[:lower:]} and @samp{[:upper:]}.
|
---|
822 |
|
---|
823 | @item [:blank:]
|
---|
824 | @opindex blank
|
---|
825 | @cindex blank characters
|
---|
826 | Blank characters:
|
---|
827 | space and tab.
|
---|
828 |
|
---|
829 | @item [:cntrl:]
|
---|
830 | @opindex cntrl
|
---|
831 | @cindex control characters
|
---|
832 | Control characters. In @sc{ascii}, these characters have octal codes 000
|
---|
833 | through 037, and 177 (@code{DEL}). In other character sets, these are
|
---|
834 | the equivalent characters, if any.
|
---|
835 |
|
---|
836 | @item [:digit:]
|
---|
837 | @opindex digit
|
---|
838 | @cindex digit characters
|
---|
839 | @cindex numeric characters
|
---|
840 | Digits: @code{0 1 2 3 4 5 6 7 8 9}.
|
---|
841 |
|
---|
842 | @item [:graph:]
|
---|
843 | @opindex graph
|
---|
844 | @cindex graphic characters
|
---|
845 | Graphical characters:
|
---|
846 | @samp{[:alnum:]} and @samp{[:punct:]}.
|
---|
847 |
|
---|
848 | @item [:lower:]
|
---|
849 | @opindex lower
|
---|
850 | @cindex lower-case letters
|
---|
851 | Lower-case letters:
|
---|
852 | @code{a b c d e f g h i j k l m n o p q r s t u v w x y z}.
|
---|
853 |
|
---|
854 | @item [:print:]
|
---|
855 | @opindex print
|
---|
856 | @cindex printable characters
|
---|
857 | Printable characters:
|
---|
858 | @samp{[:alnum:]}, @samp{[:punct:]}, and space.
|
---|
859 |
|
---|
860 | @item [:punct:]
|
---|
861 | @opindex punct
|
---|
862 | @cindex punctuation characters
|
---|
863 | Punctuation characters:
|
---|
864 | @code{!@: " # $ % & ' ( ) * + , - .@: / : ; < = > ?@: @@ [ \ ] ^ _ ` @{ | @} ~}.
|
---|
865 |
|
---|
866 | @item [:space:]
|
---|
867 | @opindex space
|
---|
868 | @cindex space characters
|
---|
869 | @cindex whitespace characters
|
---|
870 | Space characters:
|
---|
871 | tab, newline, vertical tab, form feed, carriage return, and space.
|
---|
872 |
|
---|
873 | @item [:upper:]
|
---|
874 | @opindex upper
|
---|
875 | @cindex upper-case letters
|
---|
876 | Upper-case letters:
|
---|
877 | @code{A B C D E F G H I J K L M N O P Q R S T U V W X Y Z}.
|
---|
878 |
|
---|
879 | @item [:xdigit:]
|
---|
880 | @opindex xdigit
|
---|
881 | @cindex xdigit class
|
---|
882 | @cindex hexadecimal digits
|
---|
883 | Hexadecimal digits:
|
---|
884 | @code{0 1 2 3 4 5 6 7 8 9 A B C D E F a b c d e f}.
|
---|
885 |
|
---|
886 | @end table
|
---|
887 | For example, @samp{[[:alnum:]]} means @samp{[0-9A-Za-z]}, except the latter
|
---|
888 | depends upon the C locale and the @sc{ascii} character
|
---|
889 | encoding, whereas the former is independent of locale and character set.
|
---|
890 | (Note that the brackets in these class names are
|
---|
891 | part of the symbolic names, and must be included in addition to
|
---|
892 | the brackets delimiting the bracket list.)
|
---|
893 |
|
---|
894 | Most metacharacters lose their special meaning inside lists.
|
---|
895 |
|
---|
896 | @table @samp
|
---|
897 | @item ]
|
---|
898 | ends the list if it's not the first list item. So, if you want to make
|
---|
899 | the @samp{]} character a list item, you must put it first.
|
---|
900 |
|
---|
901 | @item [.
|
---|
902 | represents the open collating symbol.
|
---|
903 |
|
---|
904 | @item .]
|
---|
905 | represents the close collating symbol.
|
---|
906 |
|
---|
907 | @item [=
|
---|
908 | represents the open equivalence class.
|
---|
909 |
|
---|
910 | @item =]
|
---|
911 | represents the close equivalence class.
|
---|
912 |
|
---|
913 | @item [:
|
---|
914 | represents the open character class followed by a valid character class name.
|
---|
915 |
|
---|
916 | @item :]
|
---|
917 | represents the close character class followed by a valid character class name.
|
---|
918 |
|
---|
919 | @item -
|
---|
920 | represents the range if it's not first or last in a list or the ending point
|
---|
921 | of a range.
|
---|
922 |
|
---|
923 | @item ^
|
---|
924 | represents the characters not in the list. If you want to make the @samp{^}
|
---|
925 | character a list item, place it anywhere but first.
|
---|
926 |
|
---|
927 | @end table
|
---|
928 |
|
---|
929 | @section Backslash Character
|
---|
930 | @cindex backslash
|
---|
931 |
|
---|
932 | The @samp{\} when followed by certain ordinary characters take a special
|
---|
933 | meaning :
|
---|
934 |
|
---|
935 | @table @samp
|
---|
936 |
|
---|
937 | @item @samp{\b}
|
---|
938 | Match the empty string at the edge of a word.
|
---|
939 |
|
---|
940 | @item @samp{\B}
|
---|
941 | Match the empty string provided it's not at the edge of a word.
|
---|
942 |
|
---|
943 | @item @samp{\<}
|
---|
944 | Match the empty string at the beginning of word.
|
---|
945 |
|
---|
946 | @item @samp{\>}
|
---|
947 | Match the empty string at the end of word.
|
---|
948 |
|
---|
949 | @item @samp{\w}
|
---|
950 | Match word constituent, it is a synonym for @samp{[[:alnum:]]}.
|
---|
951 |
|
---|
952 | @item @samp{\W}
|
---|
953 | Match non word constituent, it is a synonym for @samp{[^[:alnum:]]}.
|
---|
954 |
|
---|
955 | @end table
|
---|
956 |
|
---|
957 | For example , @samp{\brat\b} matches the separate word @samp{rat},
|
---|
958 | @samp{c\Brat\Be} matches @samp{crate}, but @samp{dirty \Brat} doesn't
|
---|
959 | match @samp{dirty rat}.
|
---|
960 |
|
---|
961 | @section Anchoring
|
---|
962 | @cindex anchoring
|
---|
963 |
|
---|
964 | The caret @samp{^} and the dollar sign @samp{$} are metacharacters that
|
---|
965 | respectively match the empty string at the beginning and end of a line.
|
---|
966 |
|
---|
967 | @section Back-reference
|
---|
968 | @cindex back-reference
|
---|
969 |
|
---|
970 | The back-reference @samp{\@var{n}}, where @var{n} is a single digit, matches
|
---|
971 | the substring previously matched by the @var{n}th parenthesized subexpression
|
---|
972 | of the regular expression. For example, @samp{(a)\1} matches @samp{aa}.
|
---|
973 | When use with alternation if the group does not participate in the match, then
|
---|
974 | the back-reference makes the whole match fail. For example, @samp{a(.)|b\1}
|
---|
975 | will not match @samp{ba}. When multiple regular expressions are given with
|
---|
976 | @samp{-e} or from a file @samp{-f file}, the back-referecences are local to
|
---|
977 | each expression.
|
---|
978 |
|
---|
979 | @section Basic vs Extended
|
---|
980 | @cindex basic regular expressions
|
---|
981 |
|
---|
982 | In basic regular expressions the metacharacters @samp{?}, @samp{+},
|
---|
983 | @samp{@{}, @samp{|}, @samp{(}, and @samp{)} lose their special meaning;
|
---|
984 | instead use the backslashed versions @samp{\?}, @samp{\+}, @samp{\@{},
|
---|
985 | @samp{\|}, @samp{\(}, and @samp{\)}.
|
---|
986 |
|
---|
987 | @cindex interval specifications
|
---|
988 | Traditional @command{egrep} did not support the @samp{@{} metacharacter,
|
---|
989 | and some @command{egrep} implementations support @samp{\@{} instead, so
|
---|
990 | portable scripts should avoid @samp{@{} in @samp{egrep} patterns and
|
---|
991 | should use @samp{[@{]} to match a literal @samp{@{}.
|
---|
992 |
|
---|
993 | @sc{gnu} @command{egrep} attempts to support traditional usage by
|
---|
994 | assuming that @samp{@{} is not special if it would be the start of an
|
---|
995 | invalid interval specification. For example, the shell command
|
---|
996 | @samp{egrep '@{1'} searches for the two-character string @samp{@{1}
|
---|
997 | instead of reporting a syntax error in the regular expression.
|
---|
998 | @sc{posix.2} allows this behavior as an extension, but portable scripts
|
---|
999 | should avoid it.
|
---|
1000 |
|
---|
1001 | @node Usage
|
---|
1002 | @chapter Usage
|
---|
1003 |
|
---|
1004 | @cindex Usage, examples
|
---|
1005 | Here is an example shell command that invokes @sc{gnu} @command{grep}:
|
---|
1006 |
|
---|
1007 | @example
|
---|
1008 | grep -i 'hello.*world' menu.h main.c
|
---|
1009 | @end example
|
---|
1010 |
|
---|
1011 | @noindent
|
---|
1012 | This lists all lines in the files @file{menu.h} and @file{main.c} that
|
---|
1013 | contain the string @samp{hello} followed by the string @samp{world};
|
---|
1014 | this is because @samp{.*} matches zero or more characters within a line.
|
---|
1015 | @xref{Regular Expressions}. The @samp{-i} option causes @command{grep}
|
---|
1016 | to ignore case, causing it to match the line @samp{Hello, world!}, which
|
---|
1017 | it would not otherwise match. @xref{Invoking}, for more details about
|
---|
1018 | how to invoke @command{grep}.
|
---|
1019 |
|
---|
1020 | @cindex Using @command{grep}, Q&A
|
---|
1021 | @cindex FAQ about @command{grep} usage
|
---|
1022 | Here are some common questions and answers about @command{grep} usage.
|
---|
1023 |
|
---|
1024 | @enumerate
|
---|
1025 |
|
---|
1026 | @item
|
---|
1027 | How can I list just the names of matching files?
|
---|
1028 |
|
---|
1029 | @example
|
---|
1030 | grep -l 'main' *.c
|
---|
1031 | @end example
|
---|
1032 |
|
---|
1033 | @noindent
|
---|
1034 | lists the names of all C files in the current directory whose contents
|
---|
1035 | mention @samp{main}.
|
---|
1036 |
|
---|
1037 | @item
|
---|
1038 | How do I search directories recursively?
|
---|
1039 |
|
---|
1040 | @example
|
---|
1041 | grep -r 'hello' /home/gigi
|
---|
1042 | @end example
|
---|
1043 |
|
---|
1044 | @noindent
|
---|
1045 | searches for @samp{hello} in all files under the directory
|
---|
1046 | @file{/home/gigi}. For more control of which files are searched, use
|
---|
1047 | @command{find}, @command{grep} and @command{xargs}. For example,
|
---|
1048 | the following command searches only C files:
|
---|
1049 |
|
---|
1050 | @smallexample
|
---|
1051 | find /home/gigi -name '*.c' -print | xargs grep 'hello' /dev/null
|
---|
1052 | @end smallexample
|
---|
1053 |
|
---|
1054 | This differs from the command:
|
---|
1055 |
|
---|
1056 | @example
|
---|
1057 | grep -r 'hello' *.c
|
---|
1058 | @end example
|
---|
1059 |
|
---|
1060 | which merely looks for @samp{hello} in all files in the current
|
---|
1061 | directory whose names end in @samp{.c}. Here the @option{-r} is
|
---|
1062 | probably unnecessary, as recursion occurs only in the unlikely event
|
---|
1063 | that one of @samp{.c} files is a directory.
|
---|
1064 |
|
---|
1065 | @item
|
---|
1066 | What if a pattern has a leading @samp{-}?
|
---|
1067 |
|
---|
1068 | @example
|
---|
1069 | grep -e '--cut here--' *
|
---|
1070 | @end example
|
---|
1071 |
|
---|
1072 | @noindent
|
---|
1073 | searches for all lines matching @samp{--cut here--}. Without @samp{-e},
|
---|
1074 | @command{grep} would attempt to parse @samp{--cut here--} as a list of
|
---|
1075 | options.
|
---|
1076 |
|
---|
1077 | @item
|
---|
1078 | Suppose I want to search for a whole word, not a part of a word?
|
---|
1079 |
|
---|
1080 | @example
|
---|
1081 | grep -w 'hello' *
|
---|
1082 | @end example
|
---|
1083 |
|
---|
1084 | @noindent
|
---|
1085 | searches only for instances of @samp{hello} that are entire words; it
|
---|
1086 | does not match @samp{Othello}. For more control, use @samp{\<} and
|
---|
1087 | @samp{\>} to match the start and end of words. For example:
|
---|
1088 |
|
---|
1089 | @example
|
---|
1090 | grep 'hello\>' *
|
---|
1091 | @end example
|
---|
1092 |
|
---|
1093 | @noindent
|
---|
1094 | searches only for words ending in @samp{hello}, so it matches the word
|
---|
1095 | @samp{Othello}.
|
---|
1096 |
|
---|
1097 | @item
|
---|
1098 | How do I output context around the matching lines?
|
---|
1099 |
|
---|
1100 | @example
|
---|
1101 | grep -C 2 'hello' *
|
---|
1102 | @end example
|
---|
1103 |
|
---|
1104 | @noindent
|
---|
1105 | prints two lines of context around each matching line.
|
---|
1106 |
|
---|
1107 | @item
|
---|
1108 | How do I force grep to print the name of the file?
|
---|
1109 |
|
---|
1110 | Append @file{/dev/null}:
|
---|
1111 |
|
---|
1112 | @example
|
---|
1113 | grep 'eli' /etc/passwd /dev/null
|
---|
1114 | @end example
|
---|
1115 |
|
---|
1116 | gets you:
|
---|
1117 |
|
---|
1118 | @smallexample
|
---|
1119 | /etc/passwd:eli:DNGUTF58.IMe.:98:11:Eli Smith:/home/do/eli:/bin/bash
|
---|
1120 | @end smallexample
|
---|
1121 |
|
---|
1122 | @item
|
---|
1123 | Why do people use strange regular expressions on @command{ps} output?
|
---|
1124 |
|
---|
1125 | @example
|
---|
1126 | ps -ef | grep '[c]ron'
|
---|
1127 | @end example
|
---|
1128 |
|
---|
1129 | If the pattern had been written without the square brackets, it would
|
---|
1130 | have matched not only the @command{ps} output line for @command{cron},
|
---|
1131 | but also the @command{ps} output line for @command{grep}.
|
---|
1132 | Note that some platforms @command{ps} limit the ouput to the width
|
---|
1133 | of the screen, grep does not have any limit on the length of a line
|
---|
1134 | except the available memory.
|
---|
1135 |
|
---|
1136 | @item
|
---|
1137 | Why does @command{grep} report ``Binary file matches''?
|
---|
1138 |
|
---|
1139 | If @command{grep} listed all matching ``lines'' from a binary file, it
|
---|
1140 | would probably generate output that is not useful, and it might even
|
---|
1141 | muck up your display. So @sc{gnu} @command{grep} suppresses output from
|
---|
1142 | files that appear to be binary files. To force @sc{gnu} @command{grep}
|
---|
1143 | to output lines even from files that appear to be binary, use the
|
---|
1144 | @samp{-a} or @samp{--binary-files=text} option. To eliminate the
|
---|
1145 | ``Binary file matches'' messages, use the @samp{-I} or
|
---|
1146 | @samp{--binary-files=without-match} option.
|
---|
1147 |
|
---|
1148 | @item
|
---|
1149 | Why doesn't @samp{grep -lv} print nonmatching file names?
|
---|
1150 |
|
---|
1151 | @samp{grep -lv} lists the names of all files containing one or more
|
---|
1152 | lines that do not match. To list the names of all files that contain no
|
---|
1153 | matching lines, use the @samp{-L} or @samp{--files-without-match}
|
---|
1154 | option.
|
---|
1155 |
|
---|
1156 | @item
|
---|
1157 | I can do @sc{or} with @samp{|}, but what about @sc{and}?
|
---|
1158 |
|
---|
1159 | @example
|
---|
1160 | grep 'paul' /etc/motd | grep 'franc,ois'
|
---|
1161 | @end example
|
---|
1162 |
|
---|
1163 | @noindent
|
---|
1164 | finds all lines that contain both @samp{paul} and @samp{franc,ois}.
|
---|
1165 |
|
---|
1166 | @item
|
---|
1167 | How can I search in both standard input and in files?
|
---|
1168 |
|
---|
1169 | Use the special file name @samp{-}:
|
---|
1170 |
|
---|
1171 | @example
|
---|
1172 | cat /etc/passwd | grep 'alain' - /etc/motd
|
---|
1173 | @end example
|
---|
1174 |
|
---|
1175 | @item
|
---|
1176 | @cindex palindromes
|
---|
1177 | How to express palindromes in a regular expression?
|
---|
1178 |
|
---|
1179 | It can be done by using the back referecences, for example a palindrome
|
---|
1180 | of 4 chararcters can be written in BRE.
|
---|
1181 |
|
---|
1182 | @example
|
---|
1183 | grep -w -e '\(.\)\(.\).\2\1' file
|
---|
1184 | @end example
|
---|
1185 |
|
---|
1186 | It matches the word "radar" or "civic".
|
---|
1187 |
|
---|
1188 | Guglielmo Bondioni proposed a single RE that finds all the palindromes up to 19
|
---|
1189 | characters long.
|
---|
1190 |
|
---|
1191 | @example
|
---|
1192 | egrep -e '^(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?).?\9\8\7\6\5\4\3\2\1$' file
|
---|
1193 | @end example
|
---|
1194 |
|
---|
1195 | Note this is done by using GNU ERE extensions, it might not be portable on
|
---|
1196 | other greps.
|
---|
1197 |
|
---|
1198 | @item
|
---|
1199 | Why are my expressions whith the vertical bar fail?
|
---|
1200 |
|
---|
1201 | @example
|
---|
1202 | /bin/echo "ba" | egrep '(a)\1|(b)\1'
|
---|
1203 | @end example
|
---|
1204 |
|
---|
1205 | The first alternate branch fails then the first group was not in the match
|
---|
1206 | this will make the second alternate branch fails. For example, "aaba" will
|
---|
1207 | match, the first group participate in the match and can be reuse in the
|
---|
1208 | second branch.
|
---|
1209 |
|
---|
1210 | @item
|
---|
1211 | What do @command{grep, fgrep, egrep} stand for ?
|
---|
1212 |
|
---|
1213 | grep comes from the way line editing was done on Unix. For example,
|
---|
1214 | @command{ed} uses this syntax to print a list of matching lines on the screen.
|
---|
1215 |
|
---|
1216 | @example
|
---|
1217 | global/regular expression/print
|
---|
1218 | g/re/p
|
---|
1219 | @end example
|
---|
1220 |
|
---|
1221 | @command{fgrep} stands for Fixed @command{grep}, @command{egrep} Extended
|
---|
1222 | @command{grep}.
|
---|
1223 |
|
---|
1224 | @end enumerate
|
---|
1225 |
|
---|
1226 | @node Reporting Bugs, Copying, Usage, Top
|
---|
1227 | @chapter Reporting bugs
|
---|
1228 |
|
---|
1229 | @cindex Bugs, reporting
|
---|
1230 | Email bug reports to @email{bug-grep@@gnu.org}.
|
---|
1231 |
|
---|
1232 | Large repetition counts in the @samp{@{n,m@}} construct may cause
|
---|
1233 | @command{grep} to use lots of memory. In addition, certain other
|
---|
1234 | obscure regular expressions require exponential time and
|
---|
1235 | space, and may cause grep to run out of memory.
|
---|
1236 | Back-references are very slow, and may require exponential time.
|
---|
1237 |
|
---|
1238 | @node Copying, GNU General Public License, Reporting Bugs, Top
|
---|
1239 | @chapter Copying
|
---|
1240 | @cindex Copying
|
---|
1241 | GNU grep is licensed under the GNU GPL, which makes it @dfn{free
|
---|
1242 | software}.
|
---|
1243 |
|
---|
1244 | Please note that ``free'' in ``free software'' refers to liberty, not
|
---|
1245 | price. As some GNU project advocates like to point out, think of ``free
|
---|
1246 | speech'' rather than ``free beer''. The exact and legally binding
|
---|
1247 | distribution terms are spelled out below; in short, you have the right
|
---|
1248 | (freedom) to run and change grep and distribute it to other people, and
|
---|
1249 | even---if you want---charge money for doing either. The important
|
---|
1250 | restriction is that you have to grant your recipients the same rights
|
---|
1251 | and impose the same restrictions.
|
---|
1252 |
|
---|
1253 | This method of licensing software is also known as @dfn{open source}
|
---|
1254 | because, among other things, it makes sure that all recipients will
|
---|
1255 | receive the source code along with the program, and be able to improve
|
---|
1256 | it. The GNU project prefers the term ``free software'' for reasons
|
---|
1257 | outlined at
|
---|
1258 | @url{http://www.gnu.org/philosophy/free-software-for-freedom.html}.
|
---|
1259 |
|
---|
1260 | The exact license terms are defined by this paragraph and the GNU
|
---|
1261 | General Public License it refers to:
|
---|
1262 |
|
---|
1263 | @quotation
|
---|
1264 | GNU grep is free software; you can redistribute it and/or modify it
|
---|
1265 | under the terms of the GNU General Public License as published by the
|
---|
1266 | Free Software Foundation; either version 2 of the License, or (at your
|
---|
1267 | option) any later version.
|
---|
1268 |
|
---|
1269 | GNU grep is distributed in the hope that it will be useful, but WITHOUT
|
---|
1270 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
---|
1271 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
---|
1272 | for more details.
|
---|
1273 |
|
---|
1274 | A copy of the GNU General Public License is included as part of this
|
---|
1275 | manual; if you did not receive it, write to the Free Software
|
---|
1276 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
1277 | @end quotation
|
---|
1278 |
|
---|
1279 | In addition to this, this manual is free in the same sense:
|
---|
1280 |
|
---|
1281 | @quotation
|
---|
1282 | Permission is granted to copy, distribute and/or modify this document
|
---|
1283 | under the terms of the GNU Free Documentation License, Version 1.1 or
|
---|
1284 | any later version published by the Free Software Foundation; with the
|
---|
1285 | Invariant Sections being ``GNU General Public License'' and ``GNU Free
|
---|
1286 | Documentation License'', with no Front-Cover Texts, and with no
|
---|
1287 | Back-Cover Texts. A copy of the license is included in the section
|
---|
1288 | entitled ``GNU Free Documentation License''.
|
---|
1289 | @end quotation
|
---|
1290 |
|
---|
1291 | @c #### Maybe we should wrap these licenses in ifinfo? Stallman says
|
---|
1292 | @c that the GFDL needs to be present in the manual, and to me it would
|
---|
1293 | @c suck to include the license for the manual and not the license for
|
---|
1294 | @c the program.
|
---|
1295 |
|
---|
1296 | The full texts of the GNU General Public License and of the GNU Free
|
---|
1297 | Documentation License are available below.
|
---|
1298 |
|
---|
1299 | @menu
|
---|
1300 | * GNU General Public License:: GNU GPL
|
---|
1301 | * GNU Free Documentation License:: GNU FDL
|
---|
1302 | @end menu
|
---|
1303 |
|
---|
1304 | @node GNU General Public License, GNU Free Documentation License, Copying, Copying
|
---|
1305 | @section GNU General Public License
|
---|
1306 | @center Version 2, June 1991
|
---|
1307 | @cindex GPL, GNU General Public License
|
---|
1308 |
|
---|
1309 | @display
|
---|
1310 | Copyright @copyright{} 1989, 1991 Free Software Foundation, Inc.
|
---|
1311 | 675 Mass Ave, Cambridge, MA 02139, USA
|
---|
1312 |
|
---|
1313 | Everyone is permitted to copy and distribute verbatim copies
|
---|
1314 | of this license document, but changing it is not allowed.
|
---|
1315 | @end display
|
---|
1316 |
|
---|
1317 | @unnumberedsec Preamble
|
---|
1318 |
|
---|
1319 | The licenses for most software are designed to take away your
|
---|
1320 | freedom to share and change it. By contrast, the GNU General Public
|
---|
1321 | License is intended to guarantee your freedom to share and change free
|
---|
1322 | software---to make sure the software is free for all its users. This
|
---|
1323 | General Public License applies to most of the Free Software
|
---|
1324 | Foundation's software and to any other program whose authors commit to
|
---|
1325 | using it. (Some other Free Software Foundation software is covered by
|
---|
1326 | the GNU Library General Public License instead.) You can apply it to
|
---|
1327 | your programs, too.
|
---|
1328 |
|
---|
1329 | When we speak of free software, we are referring to freedom, not
|
---|
1330 | price. Our General Public Licenses are designed to make sure that you
|
---|
1331 | have the freedom to distribute copies of free software (and charge for
|
---|
1332 | this service if you wish), that you receive source code or can get it
|
---|
1333 | if you want it, that you can change the software or use pieces of it
|
---|
1334 | in new free programs; and that you know you can do these things.
|
---|
1335 |
|
---|
1336 | To protect your rights, we need to make restrictions that forbid
|
---|
1337 | anyone to deny you these rights or to ask you to surrender the rights.
|
---|
1338 | These restrictions translate to certain responsibilities for you if you
|
---|
1339 | distribute copies of the software, or if you modify it.
|
---|
1340 |
|
---|
1341 | For example, if you distribute copies of such a program, whether
|
---|
1342 | gratis or for a fee, you must give the recipients all the rights that
|
---|
1343 | you have. You must make sure that they, too, receive or can get the
|
---|
1344 | source code. And you must show them these terms so they know their
|
---|
1345 | rights.
|
---|
1346 |
|
---|
1347 | We protect your rights with two steps: (1) copyright the software, and
|
---|
1348 | (2) offer you this license which gives you legal permission to copy,
|
---|
1349 | distribute and/or modify the software.
|
---|
1350 |
|
---|
1351 | Also, for each author's protection and ours, we want to make certain
|
---|
1352 | that everyone understands that there is no warranty for this free
|
---|
1353 | software. If the software is modified by someone else and passed on, we
|
---|
1354 | want its recipients to know that what they have is not the original, so
|
---|
1355 | that any problems introduced by others will not reflect on the original
|
---|
1356 | authors' reputations.
|
---|
1357 |
|
---|
1358 | Finally, any free program is threatened constantly by software
|
---|
1359 | patents. We wish to avoid the danger that redistributors of a free
|
---|
1360 | program will individually obtain patent licenses, in effect making the
|
---|
1361 | program proprietary. To prevent this, we have made it clear that any
|
---|
1362 | patent must be licensed for everyone's free use or not licensed at all.
|
---|
1363 |
|
---|
1364 | The precise terms and conditions for copying, distribution and
|
---|
1365 | modification follow.
|
---|
1366 |
|
---|
1367 | @iftex
|
---|
1368 | @unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
---|
1369 | @end iftex
|
---|
1370 | @ifinfo
|
---|
1371 | @center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
---|
1372 | @end ifinfo
|
---|
1373 |
|
---|
1374 | @enumerate
|
---|
1375 | @item
|
---|
1376 | This License applies to any program or other work which contains
|
---|
1377 | a notice placed by the copyright holder saying it may be distributed
|
---|
1378 | under the terms of this General Public License. The ``Program'', below,
|
---|
1379 | refers to any such program or work, and a ``work based on the Program''
|
---|
1380 | means either the Program or any derivative work under copyright law:
|
---|
1381 | that is to say, a work containing the Program or a portion of it,
|
---|
1382 | either verbatim or with modifications and/or translated into another
|
---|
1383 | language. (Hereinafter, translation is included without limitation in
|
---|
1384 | the term ``modification''.) Each licensee is addressed as ``you''.
|
---|
1385 |
|
---|
1386 | Activities other than copying, distribution and modification are not
|
---|
1387 | covered by this License; they are outside its scope. The act of
|
---|
1388 | running the Program is not restricted, and the output from the Program
|
---|
1389 | is covered only if its contents constitute a work based on the
|
---|
1390 | Program (independent of having been made by running the Program).
|
---|
1391 | Whether that is true depends on what the Program does.
|
---|
1392 |
|
---|
1393 | @item
|
---|
1394 | You may copy and distribute verbatim copies of the Program's
|
---|
1395 | source code as you receive it, in any medium, provided that you
|
---|
1396 | conspicuously and appropriately publish on each copy an appropriate
|
---|
1397 | copyright notice and disclaimer of warranty; keep intact all the
|
---|
1398 | notices that refer to this License and to the absence of any warranty;
|
---|
1399 | and give any other recipients of the Program a copy of this License
|
---|
1400 | along with the Program.
|
---|
1401 |
|
---|
1402 | You may charge a fee for the physical act of transferring a copy, and
|
---|
1403 | you may at your option offer warranty protection in exchange for a fee.
|
---|
1404 |
|
---|
1405 | @item
|
---|
1406 | You may modify your copy or copies of the Program or any portion
|
---|
1407 | of it, thus forming a work based on the Program, and copy and
|
---|
1408 | distribute such modifications or work under the terms of Section 1
|
---|
1409 | above, provided that you also meet all of these conditions:
|
---|
1410 |
|
---|
1411 | @enumerate a
|
---|
1412 | @item
|
---|
1413 | You must cause the modified files to carry prominent notices
|
---|
1414 | stating that you changed the files and the date of any change.
|
---|
1415 |
|
---|
1416 | @item
|
---|
1417 | You must cause any work that you distribute or publish, that in
|
---|
1418 | whole or in part contains or is derived from the Program or any
|
---|
1419 | part thereof, to be licensed as a whole at no charge to all third
|
---|
1420 | parties under the terms of this License.
|
---|
1421 |
|
---|
1422 | @item
|
---|
1423 | If the modified program normally reads commands interactively
|
---|
1424 | when run, you must cause it, when started running for such
|
---|
1425 | interactive use in the most ordinary way, to print or display an
|
---|
1426 | announcement including an appropriate copyright notice and a
|
---|
1427 | notice that there is no warranty (or else, saying that you provide
|
---|
1428 | a warranty) and that users may redistribute the program under
|
---|
1429 | these conditions, and telling the user how to view a copy of this
|
---|
1430 | License. (Exception: if the Program itself is interactive but
|
---|
1431 | does not normally print such an announcement, your work based on
|
---|
1432 | the Program is not required to print an announcement.)
|
---|
1433 | @end enumerate
|
---|
1434 |
|
---|
1435 | These requirements apply to the modified work as a whole. If
|
---|
1436 | identifiable sections of that work are not derived from the Program,
|
---|
1437 | and can be reasonably considered independent and separate works in
|
---|
1438 | themselves, then this License, and its terms, do not apply to those
|
---|
1439 | sections when you distribute them as separate works. But when you
|
---|
1440 | distribute the same sections as part of a whole which is a work based
|
---|
1441 | on the Program, the distribution of the whole must be on the terms of
|
---|
1442 | this License, whose permissions for other licensees extend to the
|
---|
1443 | entire whole, and thus to each and every part regardless of who wrote it.
|
---|
1444 |
|
---|
1445 | Thus, it is not the intent of this section to claim rights or contest
|
---|
1446 | your rights to work written entirely by you; rather, the intent is to
|
---|
1447 | exercise the right to control the distribution of derivative or
|
---|
1448 | collective works based on the Program.
|
---|
1449 |
|
---|
1450 | In addition, mere aggregation of another work not based on the Program
|
---|
1451 | with the Program (or with a work based on the Program) on a volume of
|
---|
1452 | a storage or distribution medium does not bring the other work under
|
---|
1453 | the scope of this License.
|
---|
1454 |
|
---|
1455 | @item
|
---|
1456 | You may copy and distribute the Program (or a work based on it,
|
---|
1457 | under Section 2) in object code or executable form under the terms of
|
---|
1458 | Sections 1 and 2 above provided that you also do one of the following:
|
---|
1459 |
|
---|
1460 | @enumerate a
|
---|
1461 | @item
|
---|
1462 | Accompany it with the complete corresponding machine-readable
|
---|
1463 | source code, which must be distributed under the terms of Sections
|
---|
1464 | 1 and 2 above on a medium customarily used for software interchange; or,
|
---|
1465 |
|
---|
1466 | @item
|
---|
1467 | Accompany it with a written offer, valid for at least three
|
---|
1468 | years, to give any third party, for a charge no more than your
|
---|
1469 | cost of physically performing source distribution, a complete
|
---|
1470 | machine-readable copy of the corresponding source code, to be
|
---|
1471 | distributed under the terms of Sections 1 and 2 above on a medium
|
---|
1472 | customarily used for software interchange; or,
|
---|
1473 |
|
---|
1474 | @item
|
---|
1475 | Accompany it with the information you received as to the offer
|
---|
1476 | to distribute corresponding source code. (This alternative is
|
---|
1477 | allowed only for noncommercial distribution and only if you
|
---|
1478 | received the program in object code or executable form with such
|
---|
1479 | an offer, in accord with Subsection b above.)
|
---|
1480 | @end enumerate
|
---|
1481 |
|
---|
1482 | The source code for a work means the preferred form of the work for
|
---|
1483 | making modifications to it. For an executable work, complete source
|
---|
1484 | code means all the source code for all modules it contains, plus any
|
---|
1485 | associated interface definition files, plus the scripts used to
|
---|
1486 | control compilation and installation of the executable. However, as a
|
---|
1487 | special exception, the source code distributed need not include
|
---|
1488 | anything that is normally distributed (in either source or binary
|
---|
1489 | form) with the major components (compiler, kernel, and so on) of the
|
---|
1490 | operating system on which the executable runs, unless that component
|
---|
1491 | itself accompanies the executable.
|
---|
1492 |
|
---|
1493 | If distribution of executable or object code is made by offering
|
---|
1494 | access to copy from a designated place, then offering equivalent
|
---|
1495 | access to copy the source code from the same place counts as
|
---|
1496 | distribution of the source code, even though third parties are not
|
---|
1497 | compelled to copy the source along with the object code.
|
---|
1498 |
|
---|
1499 | @item
|
---|
1500 | You may not copy, modify, sublicense, or distribute the Program
|
---|
1501 | except as expressly provided under this License. Any attempt
|
---|
1502 | otherwise to copy, modify, sublicense or distribute the Program is
|
---|
1503 | void, and will automatically terminate your rights under this License.
|
---|
1504 | However, parties who have received copies, or rights, from you under
|
---|
1505 | this License will not have their licenses terminated so long as such
|
---|
1506 | parties remain in full compliance.
|
---|
1507 |
|
---|
1508 | @item
|
---|
1509 | You are not required to accept this License, since you have not
|
---|
1510 | signed it. However, nothing else grants you permission to modify or
|
---|
1511 | distribute the Program or its derivative works. These actions are
|
---|
1512 | prohibited by law if you do not accept this License. Therefore, by
|
---|
1513 | modifying or distributing the Program (or any work based on the
|
---|
1514 | Program), you indicate your acceptance of this License to do so, and
|
---|
1515 | all its terms and conditions for copying, distributing or modifying
|
---|
1516 | the Program or works based on it.
|
---|
1517 |
|
---|
1518 | @item
|
---|
1519 | Each time you redistribute the Program (or any work based on the
|
---|
1520 | Program), the recipient automatically receives a license from the
|
---|
1521 | original licensor to copy, distribute or modify the Program subject to
|
---|
1522 | these terms and conditions. You may not impose any further
|
---|
1523 | restrictions on the recipients' exercise of the rights granted herein.
|
---|
1524 | You are not responsible for enforcing compliance by third parties to
|
---|
1525 | this License.
|
---|
1526 |
|
---|
1527 | @item
|
---|
1528 | If, as a consequence of a court judgment or allegation of patent
|
---|
1529 | infringement or for any other reason (not limited to patent issues),
|
---|
1530 | conditions are imposed on you (whether by court order, agreement or
|
---|
1531 | otherwise) that contradict the conditions of this License, they do not
|
---|
1532 | excuse you from the conditions of this License. If you cannot
|
---|
1533 | distribute so as to satisfy simultaneously your obligations under this
|
---|
1534 | License and any other pertinent obligations, then as a consequence you
|
---|
1535 | may not distribute the Program at all. For example, if a patent
|
---|
1536 | license would not permit royalty-free redistribution of the Program by
|
---|
1537 | all those who receive copies directly or indirectly through you, then
|
---|
1538 | the only way you could satisfy both it and this License would be to
|
---|
1539 | refrain entirely from distribution of the Program.
|
---|
1540 |
|
---|
1541 | If any portion of this section is held invalid or unenforceable under
|
---|
1542 | any particular circumstance, the balance of the section is intended to
|
---|
1543 | apply and the section as a whole is intended to apply in other
|
---|
1544 | circumstances.
|
---|
1545 |
|
---|
1546 | It is not the purpose of this section to induce you to infringe any
|
---|
1547 | patents or other property right claims or to contest validity of any
|
---|
1548 | such claims; this section has the sole purpose of protecting the
|
---|
1549 | integrity of the free software distribution system, which is
|
---|
1550 | implemented by public license practices. Many people have made
|
---|
1551 | generous contributions to the wide range of software distributed
|
---|
1552 | through that system in reliance on consistent application of that
|
---|
1553 | system; it is up to the author/donor to decide if he or she is willing
|
---|
1554 | to distribute software through any other system and a licensee cannot
|
---|
1555 | impose that choice.
|
---|
1556 |
|
---|
1557 | This section is intended to make thoroughly clear what is believed to
|
---|
1558 | be a consequence of the rest of this License.
|
---|
1559 |
|
---|
1560 | @item
|
---|
1561 | If the distribution and/or use of the Program is restricted in
|
---|
1562 | certain countries either by patents or by copyrighted interfaces, the
|
---|
1563 | original copyright holder who places the Program under this License
|
---|
1564 | may add an explicit geographical distribution limitation excluding
|
---|
1565 | those countries, so that distribution is permitted only in or among
|
---|
1566 | countries not thus excluded. In such case, this License incorporates
|
---|
1567 | the limitation as if written in the body of this License.
|
---|
1568 |
|
---|
1569 | @item
|
---|
1570 | The Free Software Foundation may publish revised and/or new versions
|
---|
1571 | of the General Public License from time to time. Such new versions will
|
---|
1572 | be similar in spirit to the present version, but may differ in detail to
|
---|
1573 | address new problems or concerns.
|
---|
1574 |
|
---|
1575 | Each version is given a distinguishing version number. If the Program
|
---|
1576 | specifies a version number of this License which applies to it and ``any
|
---|
1577 | later version'', you have the option of following the terms and conditions
|
---|
1578 | either of that version or of any later version published by the Free
|
---|
1579 | Software Foundation. If the Program does not specify a version number of
|
---|
1580 | this License, you may choose any version ever published by the Free Software
|
---|
1581 | Foundation.
|
---|
1582 |
|
---|
1583 | @item
|
---|
1584 | If you wish to incorporate parts of the Program into other free
|
---|
1585 | programs whose distribution conditions are different, write to the author
|
---|
1586 | to ask for permission. For software which is copyrighted by the Free
|
---|
1587 | Software Foundation, write to the Free Software Foundation; we sometimes
|
---|
1588 | make exceptions for this. Our decision will be guided by the two goals
|
---|
1589 | of preserving the free status of all derivatives of our free software and
|
---|
1590 | of promoting the sharing and reuse of software generally.
|
---|
1591 |
|
---|
1592 | @iftex
|
---|
1593 | @heading NO WARRANTY
|
---|
1594 | @end iftex
|
---|
1595 | @ifinfo
|
---|
1596 | @center NO WARRANTY
|
---|
1597 | @end ifinfo
|
---|
1598 | @cindex no warranty
|
---|
1599 |
|
---|
1600 | @item
|
---|
1601 | BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
---|
1602 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
---|
1603 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
---|
1604 | PROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
---|
1605 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
---|
1606 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
---|
1607 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
---|
1608 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
---|
1609 | REPAIR OR CORRECTION.
|
---|
1610 |
|
---|
1611 | @item
|
---|
1612 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
---|
1613 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
---|
1614 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
---|
1615 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
---|
1616 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
---|
1617 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
---|
1618 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
---|
1619 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
---|
1620 | POSSIBILITY OF SUCH DAMAGES.
|
---|
1621 | @end enumerate
|
---|
1622 |
|
---|
1623 | @iftex
|
---|
1624 | @heading END OF TERMS AND CONDITIONS
|
---|
1625 | @end iftex
|
---|
1626 | @ifinfo
|
---|
1627 | @center END OF TERMS AND CONDITIONS
|
---|
1628 | @end ifinfo
|
---|
1629 |
|
---|
1630 | @page
|
---|
1631 | @unnumberedsec How to Apply These Terms to Your New Programs
|
---|
1632 |
|
---|
1633 | If you develop a new program, and you want it to be of the greatest
|
---|
1634 | possible use to the public, the best way to achieve this is to make it
|
---|
1635 | free software which everyone can redistribute and change under these terms.
|
---|
1636 |
|
---|
1637 | To do so, attach the following notices to the program. It is safest
|
---|
1638 | to attach them to the start of each source file to most effectively
|
---|
1639 | convey the exclusion of warranty; and each file should have at least
|
---|
1640 | the ``copyright'' line and a pointer to where the full notice is found.
|
---|
1641 |
|
---|
1642 | @smallexample
|
---|
1643 | @var{one line to give the program's name and an idea of what it does.}
|
---|
1644 | Copyright (C) 19@var{yy} @var{name of author}
|
---|
1645 |
|
---|
1646 | This program is free software; you can redistribute it and/or
|
---|
1647 | modify it under the terms of the GNU General Public License
|
---|
1648 | as published by the Free Software Foundation; either version 2
|
---|
1649 | of the License, or (at your option) any later version.
|
---|
1650 |
|
---|
1651 | This program is distributed in the hope that it will be useful,
|
---|
1652 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
1653 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
1654 | GNU General Public License for more details.
|
---|
1655 |
|
---|
1656 | You should have received a copy of the GNU General Public License
|
---|
1657 | along with this program; if not, write to the Free Software
|
---|
1658 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
1659 | @end smallexample
|
---|
1660 |
|
---|
1661 | Also add information on how to contact you by electronic and paper mail.
|
---|
1662 |
|
---|
1663 | If the program is interactive, make it output a short notice like this
|
---|
1664 | when it starts in an interactive mode:
|
---|
1665 |
|
---|
1666 | @smallexample
|
---|
1667 | Gnomovision version 69, Copyright (C) 19@var{yy} @var{name of author}
|
---|
1668 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details
|
---|
1669 | type `show w'. This is free software, and you are welcome
|
---|
1670 | to redistribute it under certain conditions; type `show c'
|
---|
1671 | for details.
|
---|
1672 | @end smallexample
|
---|
1673 |
|
---|
1674 | The hypothetical commands @samp{show w} and @samp{show c} should show
|
---|
1675 | the appropriate parts of the General Public License. Of course, the
|
---|
1676 | commands you use may be called something other than @samp{show w} and
|
---|
1677 | @samp{show c}; they could even be mouse-clicks or menu items---whatever
|
---|
1678 | suits your program.
|
---|
1679 |
|
---|
1680 | You should also get your employer (if you work as a programmer) or your
|
---|
1681 | school, if any, to sign a ``copyright disclaimer'' for the program, if
|
---|
1682 | necessary. Here is a sample; alter the names:
|
---|
1683 |
|
---|
1684 | @smallexample
|
---|
1685 | @group
|
---|
1686 | Yoyodyne, Inc., hereby disclaims all copyright
|
---|
1687 | interest in the program `Gnomovision'
|
---|
1688 | (which makes passes at compilers) written
|
---|
1689 | by James Hacker.
|
---|
1690 |
|
---|
1691 | @var{signature of Ty Coon}, 1 April 1989
|
---|
1692 | Ty Coon, President of Vice
|
---|
1693 | @end group
|
---|
1694 | @end smallexample
|
---|
1695 |
|
---|
1696 | This General Public License does not permit incorporating your program into
|
---|
1697 | proprietary programs. If your program is a subroutine library, you may
|
---|
1698 | consider it more useful to permit linking proprietary applications with the
|
---|
1699 | library. If this is what you want to do, use the GNU Library General
|
---|
1700 | Public License instead of this License.
|
---|
1701 |
|
---|
1702 | @node GNU Free Documentation License, Concept Index, GNU General Public License, Copying
|
---|
1703 | @section GNU Free Documentation License
|
---|
1704 | @center Version 1.1, March 2000
|
---|
1705 | @cindex FDL, GNU Free Documentation License
|
---|
1706 |
|
---|
1707 | @display
|
---|
1708 | Copyright (C) 2000 Free Software Foundation, Inc.
|
---|
1709 | 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
1710 |
|
---|
1711 | Everyone is permitted to copy and distribute verbatim copies
|
---|
1712 | of this license document, but changing it is not allowed.
|
---|
1713 | @end display
|
---|
1714 | @sp 1
|
---|
1715 | @enumerate 0
|
---|
1716 | @item
|
---|
1717 | PREAMBLE
|
---|
1718 |
|
---|
1719 | The purpose of this License is to make a manual, textbook, or other
|
---|
1720 | written document ``free'' in the sense of freedom: to assure everyone
|
---|
1721 | the effective freedom to copy and redistribute it, with or without
|
---|
1722 | modifying it, either commercially or noncommercially. Secondarily,
|
---|
1723 | this License preserves for the author and publisher a way to get
|
---|
1724 | credit for their work, while not being considered responsible for
|
---|
1725 | modifications made by others.
|
---|
1726 |
|
---|
1727 | This License is a kind of ``copyleft'', which means that derivative
|
---|
1728 | works of the document must themselves be free in the same sense. It
|
---|
1729 | complements the GNU General Public License, which is a copyleft
|
---|
1730 | license designed for free software.
|
---|
1731 |
|
---|
1732 | We have designed this License in order to use it for manuals for free
|
---|
1733 | software, because free software needs free documentation: a free
|
---|
1734 | program should come with manuals providing the same freedoms that the
|
---|
1735 | software does. But this License is not limited to software manuals;
|
---|
1736 | it can be used for any textual work, regardless of subject matter or
|
---|
1737 | whether it is published as a printed book. We recommend this License
|
---|
1738 | principally for works whose purpose is instruction or reference.
|
---|
1739 |
|
---|
1740 | @sp 1
|
---|
1741 | @item
|
---|
1742 | APPLICABILITY AND DEFINITIONS
|
---|
1743 |
|
---|
1744 | This License applies to any manual or other work that contains a
|
---|
1745 | notice placed by the copyright holder saying it can be distributed
|
---|
1746 | under the terms of this License. The ``Document'', below, refers to any
|
---|
1747 | such manual or work. Any member of the public is a licensee, and is
|
---|
1748 | addressed as ``you''.
|
---|
1749 |
|
---|
1750 | A ``Modified Version'' of the Document means any work containing the
|
---|
1751 | Document or a portion of it, either copied verbatim, or with
|
---|
1752 | modifications and/or translated into another language.
|
---|
1753 |
|
---|
1754 | A ``Secondary Section'' is a named appendix or a front-matter section of
|
---|
1755 | the Document that deals exclusively with the relationship of the
|
---|
1756 | publishers or authors of the Document to the Document's overall subject
|
---|
1757 | (or to related matters) and contains nothing that could fall directly
|
---|
1758 | within that overall subject. (For example, if the Document is in part a
|
---|
1759 | textbook of mathematics, a Secondary Section may not explain any
|
---|
1760 | mathematics.) The relationship could be a matter of historical
|
---|
1761 | connection with the subject or with related matters, or of legal,
|
---|
1762 | commercial, philosophical, ethical or political position regarding
|
---|
1763 | them.
|
---|
1764 |
|
---|
1765 | The ``Invariant Sections'' are certain Secondary Sections whose titles
|
---|
1766 | are designated, as being those of Invariant Sections, in the notice
|
---|
1767 | that says that the Document is released under this License.
|
---|
1768 |
|
---|
1769 | The ``Cover Texts'' are certain short passages of text that are listed,
|
---|
1770 | as Front-Cover Texts or Back-Cover Texts, in the notice that says that
|
---|
1771 | the Document is released under this License.
|
---|
1772 |
|
---|
1773 | A ``Transparent'' copy of the Document means a machine-readable copy,
|
---|
1774 | represented in a format whose specification is available to the
|
---|
1775 | general public, whose contents can be viewed and edited directly and
|
---|
1776 | straightforwardly with generic text editors or (for images composed of
|
---|
1777 | pixels) generic paint programs or (for drawings) some widely available
|
---|
1778 | drawing editor, and that is suitable for input to text formatters or
|
---|
1779 | for automatic translation to a variety of formats suitable for input
|
---|
1780 | to text formatters. A copy made in an otherwise Transparent file
|
---|
1781 | format whose markup has been designed to thwart or discourage
|
---|
1782 | subsequent modification by readers is not Transparent. A copy that is
|
---|
1783 | not ``Transparent'' is called ``Opaque''.
|
---|
1784 |
|
---|
1785 | Examples of suitable formats for Transparent copies include plain
|
---|
1786 | ASCII without markup, Texinfo input format, LaTeX input format, SGML
|
---|
1787 | or XML using a publicly available DTD, and standard-conforming simple
|
---|
1788 | HTML designed for human modification. Opaque formats include
|
---|
1789 | PostScript, PDF, proprietary formats that can be read and edited only
|
---|
1790 | by proprietary word processors, SGML or XML for which the DTD and/or
|
---|
1791 | processing tools are not generally available, and the
|
---|
1792 | machine-generated HTML produced by some word processors for output
|
---|
1793 | purposes only.
|
---|
1794 |
|
---|
1795 | The ``Title Page'' means, for a printed book, the title page itself,
|
---|
1796 | plus such following pages as are needed to hold, legibly, the material
|
---|
1797 | this License requires to appear in the title page. For works in
|
---|
1798 | formats which do not have any title page as such, ``Title Page'' means
|
---|
1799 | the text near the most prominent appearance of the work's title,
|
---|
1800 | preceding the beginning of the body of the text.
|
---|
1801 | @sp 1
|
---|
1802 | @item
|
---|
1803 | VERBATIM COPYING
|
---|
1804 |
|
---|
1805 | You may copy and distribute the Document in any medium, either
|
---|
1806 | commercially or noncommercially, provided that this License, the
|
---|
1807 | copyright notices, and the license notice saying this License applies
|
---|
1808 | to the Document are reproduced in all copies, and that you add no other
|
---|
1809 | conditions whatsoever to those of this License. You may not use
|
---|
1810 | technical measures to obstruct or control the reading or further
|
---|
1811 | copying of the copies you make or distribute. However, you may accept
|
---|
1812 | compensation in exchange for copies. If you distribute a large enough
|
---|
1813 | number of copies you must also follow the conditions in section 3.
|
---|
1814 |
|
---|
1815 | You may also lend copies, under the same conditions stated above, and
|
---|
1816 | you may publicly display copies.
|
---|
1817 | @sp 1
|
---|
1818 | @item
|
---|
1819 | COPYING IN QUANTITY
|
---|
1820 |
|
---|
1821 | If you publish printed copies of the Document numbering more than 100,
|
---|
1822 | and the Document's license notice requires Cover Texts, you must enclose
|
---|
1823 | the copies in covers that carry, clearly and legibly, all these Cover
|
---|
1824 | Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
|
---|
1825 | the back cover. Both covers must also clearly and legibly identify
|
---|
1826 | you as the publisher of these copies. The front cover must present
|
---|
1827 | the full title with all words of the title equally prominent and
|
---|
1828 | visible. You may add other material on the covers in addition.
|
---|
1829 | Copying with changes limited to the covers, as long as they preserve
|
---|
1830 | the title of the Document and satisfy these conditions, can be treated
|
---|
1831 | as verbatim copying in other respects.
|
---|
1832 |
|
---|
1833 | If the required texts for either cover are too voluminous to fit
|
---|
1834 | legibly, you should put the first ones listed (as many as fit
|
---|
1835 | reasonably) on the actual cover, and continue the rest onto adjacent
|
---|
1836 | pages.
|
---|
1837 |
|
---|
1838 | If you publish or distribute Opaque copies of the Document numbering
|
---|
1839 | more than 100, you must either include a machine-readable Transparent
|
---|
1840 | copy along with each Opaque copy, or state in or with each Opaque copy
|
---|
1841 | a publicly-accessible computer-network location containing a complete
|
---|
1842 | Transparent copy of the Document, free of added material, which the
|
---|
1843 | general network-using public has access to download anonymously at no
|
---|
1844 | charge using public-standard network protocols. If you use the latter
|
---|
1845 | option, you must take reasonably prudent steps, when you begin
|
---|
1846 | distribution of Opaque copies in quantity, to ensure that this
|
---|
1847 | Transparent copy will remain thus accessible at the stated location
|
---|
1848 | until at least one year after the last time you distribute an Opaque
|
---|
1849 | copy (directly or through your agents or retailers) of that edition to
|
---|
1850 | the public.
|
---|
1851 |
|
---|
1852 | It is requested, but not required, that you contact the authors of the
|
---|
1853 | Document well before redistributing any large number of copies, to give
|
---|
1854 | them a chance to provide you with an updated version of the Document.
|
---|
1855 | @sp 1
|
---|
1856 | @item
|
---|
1857 | MODIFICATIONS
|
---|
1858 |
|
---|
1859 | You may copy and distribute a Modified Version of the Document under
|
---|
1860 | the conditions of sections 2 and 3 above, provided that you release
|
---|
1861 | the Modified Version under precisely this License, with the Modified
|
---|
1862 | Version filling the role of the Document, thus licensing distribution
|
---|
1863 | and modification of the Modified Version to whoever possesses a copy
|
---|
1864 | of it. In addition, you must do these things in the Modified Version:
|
---|
1865 |
|
---|
1866 | A. Use in the Title Page (and on the covers, if any) a title distinct
|
---|
1867 | from that of the Document, and from those of previous versions
|
---|
1868 | (which should, if there were any, be listed in the History section
|
---|
1869 | of the Document). You may use the same title as a previous version
|
---|
1870 | if the original publisher of that version gives permission.@*
|
---|
1871 | B. List on the Title Page, as authors, one or more persons or entities
|
---|
1872 | responsible for authorship of the modifications in the Modified
|
---|
1873 | Version, together with at least five of the principal authors of the
|
---|
1874 | Document (all of its principal authors, if it has less than five).@*
|
---|
1875 | C. State on the Title page the name of the publisher of the
|
---|
1876 | Modified Version, as the publisher.@*
|
---|
1877 | D. Preserve all the copyright notices of the Document.@*
|
---|
1878 | E. Add an appropriate copyright notice for your modifications
|
---|
1879 | adjacent to the other copyright notices.@*
|
---|
1880 | F. Include, immediately after the copyright notices, a license notice
|
---|
1881 | giving the public permission to use the Modified Version under the
|
---|
1882 | terms of this License, in the form shown in the Addendum below.@*
|
---|
1883 | G. Preserve in that license notice the full lists of Invariant Sections
|
---|
1884 | and required Cover Texts given in the Document's license notice.@*
|
---|
1885 | H. Include an unaltered copy of this License.@*
|
---|
1886 | I. Preserve the section entitled ``History'', and its title, and add to
|
---|
1887 | it an item stating at least the title, year, new authors, and
|
---|
1888 | publisher of the Modified Version as given on the Title Page. If
|
---|
1889 | there is no section entitled ``History'' in the Document, create one
|
---|
1890 | stating the title, year, authors, and publisher of the Document as
|
---|
1891 | given on its Title Page, then add an item describing the Modified
|
---|
1892 | Version as stated in the previous sentence.@*
|
---|
1893 | J. Preserve the network location, if any, given in the Document for
|
---|
1894 | public access to a Transparent copy of the Document, and likewise
|
---|
1895 | the network locations given in the Document for previous versions
|
---|
1896 | it was based on. These may be placed in the ``History'' section.
|
---|
1897 | You may omit a network location for a work that was published at
|
---|
1898 | least four years before the Document itself, or if the original
|
---|
1899 | publisher of the version it refers to gives permission.@*
|
---|
1900 | K. In any section entitled ``Acknowledgements'' or ``Dedications'',
|
---|
1901 | preserve the section's title, and preserve in the section all the
|
---|
1902 | substance and tone of each of the contributor acknowledgements
|
---|
1903 | and/or dedications given therein.@*
|
---|
1904 | L. Preserve all the Invariant Sections of the Document,
|
---|
1905 | unaltered in their text and in their titles. Section numbers
|
---|
1906 | or the equivalent are not considered part of the section titles.@*
|
---|
1907 | M. Delete any section entitled ``Endorsements''. Such a section
|
---|
1908 | may not be included in the Modified Version.@*
|
---|
1909 | N. Do not retitle any existing section as ``Endorsements''
|
---|
1910 | or to conflict in title with any Invariant Section.@*
|
---|
1911 | @sp 1
|
---|
1912 | If the Modified Version includes new front-matter sections or
|
---|
1913 | appendices that qualify as Secondary Sections and contain no material
|
---|
1914 | copied from the Document, you may at your option designate some or all
|
---|
1915 | of these sections as invariant. To do this, add their titles to the
|
---|
1916 | list of Invariant Sections in the Modified Version's license notice.
|
---|
1917 | These titles must be distinct from any other section titles.
|
---|
1918 |
|
---|
1919 | You may add a section entitled ``Endorsements'', provided it contains
|
---|
1920 | nothing but endorsements of your Modified Version by various
|
---|
1921 | parties--for example, statements of peer review or that the text has
|
---|
1922 | been approved by an organization as the authoritative definition of a
|
---|
1923 | standard.
|
---|
1924 |
|
---|
1925 | You may add a passage of up to five words as a Front-Cover Text, and a
|
---|
1926 | passage of up to 25 words as a Back-Cover Text, to the end of the list
|
---|
1927 | of Cover Texts in the Modified Version. Only one passage of
|
---|
1928 | Front-Cover Text and one of Back-Cover Text may be added by (or
|
---|
1929 | through arrangements made by) any one entity. If the Document already
|
---|
1930 | includes a cover text for the same cover, previously added by you or
|
---|
1931 | by arrangement made by the same entity you are acting on behalf of,
|
---|
1932 | you may not add another; but you may replace the old one, on explicit
|
---|
1933 | permission from the previous publisher that added the old one.
|
---|
1934 |
|
---|
1935 | The author(s) and publisher(s) of the Document do not by this License
|
---|
1936 | give permission to use their names for publicity for or to assert or
|
---|
1937 | imply endorsement of any Modified Version.
|
---|
1938 | @sp 1
|
---|
1939 | @item
|
---|
1940 | COMBINING DOCUMENTS
|
---|
1941 |
|
---|
1942 | You may combine the Document with other documents released under this
|
---|
1943 | License, under the terms defined in section 4 above for modified
|
---|
1944 | versions, provided that you include in the combination all of the
|
---|
1945 | Invariant Sections of all of the original documents, unmodified, and
|
---|
1946 | list them all as Invariant Sections of your combined work in its
|
---|
1947 | license notice.
|
---|
1948 |
|
---|
1949 | The combined work need only contain one copy of this License, and
|
---|
1950 | multiple identical Invariant Sections may be replaced with a single
|
---|
1951 | copy. If there are multiple Invariant Sections with the same name but
|
---|
1952 | different contents, make the title of each such section unique by
|
---|
1953 | adding at the end of it, in parentheses, the name of the original
|
---|
1954 | author or publisher of that section if known, or else a unique number.
|
---|
1955 | Make the same adjustment to the section titles in the list of
|
---|
1956 | Invariant Sections in the license notice of the combined work.
|
---|
1957 |
|
---|
1958 | In the combination, you must combine any sections entitled ``History''
|
---|
1959 | in the various original documents, forming one section entitled
|
---|
1960 | ``History''; likewise combine any sections entitled ``Acknowledgements'',
|
---|
1961 | and any sections entitled ``Dedications''. You must delete all sections
|
---|
1962 | entitled ``Endorsements.''
|
---|
1963 | @sp 1
|
---|
1964 | @item
|
---|
1965 | COLLECTIONS OF DOCUMENTS
|
---|
1966 |
|
---|
1967 | You may make a collection consisting of the Document and other documents
|
---|
1968 | released under this License, and replace the individual copies of this
|
---|
1969 | License in the various documents with a single copy that is included in
|
---|
1970 | the collection, provided that you follow the rules of this License for
|
---|
1971 | verbatim copying of each of the documents in all other respects.
|
---|
1972 |
|
---|
1973 | You may extract a single document from such a collection, and distribute
|
---|
1974 | it individually under this License, provided you insert a copy of this
|
---|
1975 | License into the extracted document, and follow this License in all
|
---|
1976 | other respects regarding verbatim copying of that document.
|
---|
1977 | @sp 1
|
---|
1978 | @item
|
---|
1979 | AGGREGATION WITH INDEPENDENT WORKS
|
---|
1980 |
|
---|
1981 | A compilation of the Document or its derivatives with other separate
|
---|
1982 | and independent documents or works, in or on a volume of a storage or
|
---|
1983 | distribution medium, does not as a whole count as a Modified Version
|
---|
1984 | of the Document, provided no compilation copyright is claimed for the
|
---|
1985 | compilation. Such a compilation is called an ``aggregate'', and this
|
---|
1986 | License does not apply to the other self-contained works thus compiled
|
---|
1987 | with the Document, on account of their being thus compiled, if they
|
---|
1988 | are not themselves derivative works of the Document.
|
---|
1989 |
|
---|
1990 | If the Cover Text requirement of section 3 is applicable to these
|
---|
1991 | copies of the Document, then if the Document is less than one quarter
|
---|
1992 | of the entire aggregate, the Document's Cover Texts may be placed on
|
---|
1993 | covers that surround only the Document within the aggregate.
|
---|
1994 | Otherwise they must appear on covers around the whole aggregate.
|
---|
1995 | @sp 1
|
---|
1996 | @item
|
---|
1997 | TRANSLATION
|
---|
1998 |
|
---|
1999 | Translation is considered a kind of modification, so you may
|
---|
2000 | distribute translations of the Document under the terms of section 4.
|
---|
2001 | Replacing Invariant Sections with translations requires special
|
---|
2002 | permission from their copyright holders, but you may include
|
---|
2003 | translations of some or all Invariant Sections in addition to the
|
---|
2004 | original versions of these Invariant Sections. You may include a
|
---|
2005 | translation of this License provided that you also include the
|
---|
2006 | original English version of this License. In case of a disagreement
|
---|
2007 | between the translation and the original English version of this
|
---|
2008 | License, the original English version will prevail.
|
---|
2009 | @sp 1
|
---|
2010 | @item
|
---|
2011 | TERMINATION
|
---|
2012 |
|
---|
2013 | You may not copy, modify, sublicense, or distribute the Document except
|
---|
2014 | as expressly provided for under this License. Any other attempt to
|
---|
2015 | copy, modify, sublicense or distribute the Document is void, and will
|
---|
2016 | automatically terminate your rights under this License. However,
|
---|
2017 | parties who have received copies, or rights, from you under this
|
---|
2018 | License will not have their licenses terminated so long as such
|
---|
2019 | parties remain in full compliance.
|
---|
2020 | @sp 1
|
---|
2021 | @item
|
---|
2022 | FUTURE REVISIONS OF THIS LICENSE
|
---|
2023 |
|
---|
2024 | The Free Software Foundation may publish new, revised versions
|
---|
2025 | of the GNU Free Documentation License from time to time. Such new
|
---|
2026 | versions will be similar in spirit to the present version, but may
|
---|
2027 | differ in detail to address new problems or concerns. See
|
---|
2028 | http://www.gnu.org/copyleft/.
|
---|
2029 |
|
---|
2030 | Each version of the License is given a distinguishing version number.
|
---|
2031 | If the Document specifies that a particular numbered version of this
|
---|
2032 | License ``or any later version'' applies to it, you have the option of
|
---|
2033 | following the terms and conditions either of that specified version or
|
---|
2034 | of any later version that has been published (not as a draft) by the
|
---|
2035 | Free Software Foundation. If the Document does not specify a version
|
---|
2036 | number of this License, you may choose any version ever published (not
|
---|
2037 | as a draft) by the Free Software Foundation.
|
---|
2038 |
|
---|
2039 | @end enumerate
|
---|
2040 |
|
---|
2041 | @unnumberedsec ADDENDUM: How to use this License for your documents
|
---|
2042 |
|
---|
2043 | To use this License in a document you have written, include a copy of
|
---|
2044 | the License in the document and put the following copyright and
|
---|
2045 | license notices just after the title page:
|
---|
2046 |
|
---|
2047 | @smallexample
|
---|
2048 | @group
|
---|
2049 |
|
---|
2050 | Copyright (C) @var{year} @var{your name}.
|
---|
2051 | Permission is granted to copy, distribute and/or modify this document
|
---|
2052 | under the terms of the GNU Free Documentation License, Version 1.1
|
---|
2053 | or any later version published by the Free Software Foundation;
|
---|
2054 | with the Invariant Sections being @var{list their titles}, with the
|
---|
2055 | Front-Cover Texts being @var{list}, and with the Back-Cover Texts being @var{list}.
|
---|
2056 | A copy of the license is included in the section entitled ``GNU
|
---|
2057 | Free Documentation License''.
|
---|
2058 | @end group
|
---|
2059 | @end smallexample
|
---|
2060 | If you have no Invariant Sections, write ``with no Invariant Sections''
|
---|
2061 | instead of saying which ones are invariant. If you have no
|
---|
2062 | Front-Cover Texts, write ``no Front-Cover Texts'' instead of
|
---|
2063 | ``Front-Cover Texts being @var{list}''; likewise for Back-Cover Texts.
|
---|
2064 |
|
---|
2065 | If your document contains nontrivial examples of program code, we
|
---|
2066 | recommend releasing these examples in parallel under your choice of
|
---|
2067 | free software license, such as the GNU General Public License,
|
---|
2068 | to permit their use in free software.
|
---|
2069 |
|
---|
2070 | @page
|
---|
2071 | @node Concept Index, Index, GNU Free Documentation License, Top
|
---|
2072 | @unnumbered Concept Index
|
---|
2073 |
|
---|
2074 | This is a general index of all issues discussed in this manual, with the
|
---|
2075 | exception of the @command{grep} commands and command-line options.
|
---|
2076 |
|
---|
2077 | @printindex cp
|
---|
2078 |
|
---|
2079 | @page
|
---|
2080 | @node Index,, Concept Index, Top
|
---|
2081 | @unnumbered Index
|
---|
2082 |
|
---|
2083 | This is an alphabetical list of all @command{grep} commands, command-line
|
---|
2084 | options, and environment variables.
|
---|
2085 |
|
---|
2086 | @printindex fn
|
---|
2087 |
|
---|
2088 | @contents
|
---|
2089 | @bye
|
---|