153564Sobrien\input texinfo @c -*-texinfo-*- 253564Sobrien@c %**start of header 353564Sobrien@setfilename grep.info 453564Sobrien@settitle grep, print lines matching a pattern 553564Sobrien@c %**end of header 653564Sobrien 753564Sobrien@c This file has the new style title page commands. 853564Sobrien@c Run `makeinfo' rather than `texinfo-format-buffer'. 953564Sobrien 1053564Sobrien@c smallbook 1153564Sobrien 1253564Sobrien@c tex 1353564Sobrien@c \overfullrule=0pt 1453564Sobrien@c end tex 1553564Sobrien 1653564Sobrien@include version.texi 1753564Sobrien 1853564Sobrien@c Combine indices. 1953564Sobrien@syncodeindex ky cp 2053564Sobrien@syncodeindex pg cp 2153564Sobrien@syncodeindex tp cp 2253564Sobrien 2353564Sobrien@defcodeindex op 2453564Sobrien@syncodeindex op fn 2555360Sobrien@syncodeindex vr fn 2653564Sobrien 2753564Sobrien@ifinfo 2853564Sobrien@direntry 2953564Sobrien* grep: (grep). print lines matching a pattern. 3053564Sobrien@end direntry 3155360SobrienThis file documents @command{grep}, a pattern matching engine. 3253564Sobrien 3353564Sobrien 3453564SobrienPublished by the Free Software Foundation, 3553564Sobrien59 Temple Place - Suite 330 3653564SobrienBoston, MA 02111-1307, USA 3753564Sobrien 38131554Stjr@c man begin COPYRIGHT 39131554StjrCopyright @copyright{} 2000, 2001 Free Software Foundation, Inc. 4053564Sobrien 4153564SobrienPermission is granted to make and distribute verbatim copies of 4253564Sobrienthis manual provided the copyright notice and this permission notice 4353564Sobrienare preserved on all copies. 4453564Sobrien 4553564Sobrien@ignore 4653564SobrienPermission is granted to process this file through TeX and print the 47131554Stjrresults, provided the printed document carries a copying permission 4853564Sobriennotice identical to this one except for the removal of this paragraph 4953564Sobrien(this paragraph not being relevant to the printed manual). 5053564Sobrien 5153564Sobrien@end ignore 52131554StjrPermission is granted to copy, distribute and/or modify this document 53131554Stjrunder the terms of the GNU Free Documentation License, Version 1.1 or 54131554Stjrany later version published by the Free Software Foundation; with the 55131554StjrInvariant Sections being ``GNU General Public License'' and ``GNU Free 56131554StjrDocumentation License'', with no Front-Cover Texts, and with no 57131554StjrBack-Cover Texts. A copy of the license is included in the section 58131554Stjrentitled ``GNU Free Documentation License'' (@pxref{Copying}). 59131554Stjr@c man end 6053564Sobrien@end ifinfo 6153564Sobrien 6253564Sobrien@setchapternewpage off 6353564Sobrien 6453564Sobrien@titlepage 6553564Sobrien@title grep, searching for a pattern 6653564Sobrien@subtitle version @value{VERSION}, @value{UPDATED} 6753564Sobrien@author Alain Magloire et al. 6853564Sobrien 6953564Sobrien@page 7053564Sobrien@vskip 0pt plus 1filll 71131554StjrCopyright @copyright{} 2000, 2001 Free Software Foundation, Inc. 7253564Sobrien 7353564Sobrien@sp 2 7453564SobrienPublished by the Free Software Foundation, @* 7553564Sobrien59 Temple Place - Suite 330, @* 7653564SobrienBoston, MA 02111-1307, USA 7753564Sobrien 78131554StjrPermission is granted to copy, distribute and/or modify this document 79131554Stjrunder the terms of the GNU Free Documentation License, Version 1.1 or 80131554Stjrany later version published by the Free Software Foundation; with the 81131554StjrInvariant Sections being ``GNU General Public License'' and ``GNU Free 82131554StjrDocumentation License'', with no Front-Cover Texts, and with no 83131554StjrBack-Cover Texts. A copy of the license is included in the section 84131554Stjrentitled ``GNU Free Documentation License''. 8553564Sobrien@end titlepage 8653564Sobrien 8753564Sobrien 8855360Sobrien@ifnottex 8955360Sobrien@node Top 9055360Sobrien@top Grep 9153564Sobrien 9255360Sobrien@command{grep} searches for lines matching a pattern. 9353564Sobrien 9455360SobrienThis document was produced for version @value{VERSION} of @sc{gnu} 9555360Sobrien@command{grep}. 9655360Sobrien@end ifnottex 9755360Sobrien 9853564Sobrien@menu 9953564Sobrien* Introduction:: Introduction. 10055360Sobrien* Invoking:: Invoking @command{grep}; description of options. 10155360Sobrien* Diagnostics:: Exit status returned by @command{grep}. 10255360Sobrien* Grep Programs:: @command{grep} programs. 10353564Sobrien* Regular Expressions:: Regular Expressions. 10455360Sobrien* Usage:: Examples. 10553564Sobrien* Reporting Bugs:: Reporting Bugs. 106131554Stjr* Copying:: License terms. 10753564Sobrien* Concept Index:: A menu with all the topics in this manual. 10855360Sobrien* Index:: A menu with all @command{grep} commands 10953564Sobrien and command-line options. 11053564Sobrien@end menu 11153564Sobrien 11253564Sobrien 113131554Stjr@node Introduction, Invoking, Top, Top 11453564Sobrien@chapter Introduction 11553564Sobrien 11653564Sobrien@cindex Searching for a pattern. 11755360Sobrien 11855360Sobrien@command{grep} searches the input files 11955360Sobrienfor lines containing a match to a given 12053564Sobrienpattern list. When it finds a match in a line, it copies the line to standard 12153564Sobrienoutput (by default), or does whatever other sort of output you have requested 12256915Sruwith options. 12356915Sru 12456915SruThough @command{grep} expects to do the matching on text, 12556915Sruit has no limits on input line length other than available memory, 12656915Sruand it can match arbitrary characters within a line. 12756915SruIf the final byte of an input file is not a newline, 12856915Sru@command{grep} silently supplies one. 12953564SobrienSince newline is also a separator for the list of patterns, there 13053564Sobrienis no way to match newline characters in a text. 13153564Sobrien 13255360Sobrien@node Invoking 13355360Sobrien@chapter Invoking @command{grep} 13453564Sobrien 13555360Sobrien@command{grep} comes with a rich set of options from @sc{posix.2} and @sc{gnu} 13655360Sobrienextensions. 13753564Sobrien 13853564Sobrien@table @samp 13953564Sobrien 14053564Sobrien@item -c 14153564Sobrien@itemx --count 14253564Sobrien@opindex -c 143131554Stjr@opindex --count 14453564Sobrien@cindex counting lines 14553564SobrienSuppress normal output; instead print a count of matching 14655360Sobrienlines for each input file. With the @samp{-v}, @samp{--invert-match} option, 14753564Sobriencount non-matching lines. 14853564Sobrien 14953564Sobrien@item -e @var{pattern} 15053564Sobrien@itemx --regexp=@var{pattern} 15153564Sobrien@opindex -e 15253564Sobrien@opindex --regexp=@var{pattern} 15353564Sobrien@cindex pattern list 15455360SobrienUse @var{pattern} as the pattern; useful to protect patterns 15553564Sobrienbeginning with a @samp{-}. 15653564Sobrien 15755360Sobrien@item -f @var{file} 15853564Sobrien@itemx --file=@var{file} 15955360Sobrien@opindex -f 16055360Sobrien@opindex --file 16153564Sobrien@cindex pattern from file 16255360SobrienObtain patterns from @var{file}, one per line. The empty 16353564Sobrienfile contains zero patterns, and therefore matches nothing. 16453564Sobrien 16553564Sobrien@item -i 16653564Sobrien@itemx --ignore-case 16753564Sobrien@opindex -i 16853564Sobrien@opindex --ignore-case 16953564Sobrien@cindex case insensitive search 17055360SobrienIgnore case distinctions in both the pattern and the input files. 17153564Sobrien 17253564Sobrien@item -l 17353564Sobrien@itemx --files-with-matches 17453564Sobrien@opindex -l 17553564Sobrien@opindex --files-with-matches 17653564Sobrien@cindex names of matching files 17755360SobrienSuppress normal output; instead print the name of each input 17855360Sobrienfile from which output would normally have been printed. 17953564SobrienThe scanning of every file will stop on the first match. 18053564Sobrien 18153564Sobrien@item -n 18253564Sobrien@itemx --line-number 18353564Sobrien@opindex -n 18453564Sobrien@opindex --line-number 18553564Sobrien@cindex line numbering 18655360SobrienPrefix each line of output with the line number within its input file. 18753564Sobrien 188131554Stjr@item -o 189131554Stjr@itemx --only-matching 190131554Stjr@opindex -o 191131554Stjr@opindex --only-matching 192131554Stjr@cindex only matching 193131554StjrPrint only the part of matching lines that actually matches @var{pattern}. 194131554Stjr 19553564Sobrien@item -q 19653564Sobrien@itemx --quiet 19753564Sobrien@itemx --silent 19853564Sobrien@opindex -q 19953564Sobrien@opindex --quiet 20053564Sobrien@opindex --silent 20153564Sobrien@cindex quiet, silent 202131554StjrQuiet; do not write anything to standard output. Exit immediately with 203131554Stjrzero status if any match is found, even if an error was detected. Also 204131554Stjrsee the @samp{-s} or @samp{--no-messages} option. 20553564Sobrien 20653564Sobrien@item -s 20753564Sobrien@itemx --no-messages 20853564Sobrien@opindex -s 20953564Sobrien@opindex --no-messages 21053564Sobrien@cindex suppress error messages 21153564SobrienSuppress error messages about nonexistent or unreadable files. 21255360SobrienPortability note: unlike @sc{gnu} @command{grep}, traditional 21355360Sobrien@command{grep} did not conform to @sc{posix.2}, because traditional 21455360Sobrien@command{grep} lacked a @samp{-q} option and its @samp{-s} option behaved 21555360Sobrienlike @sc{gnu} @command{grep}'s @samp{-q} option. Shell scripts intended 21655360Sobriento be portable to traditional @command{grep} should avoid both 21753564Sobrien@samp{-q} and @samp{-s} and should redirect 21853564Sobrienoutput to @file{/dev/null} instead. 21953564Sobrien 22053564Sobrien@item -v 22155360Sobrien@itemx --invert-match 22253564Sobrien@opindex -v 22355360Sobrien@opindex --invert-match 22455360Sobrien@cindex invert matching 22553564Sobrien@cindex print non-matching lines 22655360SobrienInvert the sense of matching, to select non-matching lines. 22753564Sobrien 22853564Sobrien@item -x 22953564Sobrien@itemx --line-regexp 23053564Sobrien@opindex -x 23153564Sobrien@opindex --line-regexp 23253564Sobrien@cindex match the whole line 23355360SobrienSelect only those matches that exactly match the whole line. 23453564Sobrien 23553564Sobrien@end table 23653564Sobrien 23755360Sobrien@section @sc{gnu} Extensions 23853564Sobrien 23953564Sobrien@table @samp 24053564Sobrien 24153564Sobrien@item -A @var{num} 24253564Sobrien@itemx --after-context=@var{num} 24353564Sobrien@opindex -A 24453564Sobrien@opindex --after-context 24553564Sobrien@cindex after context 24653564Sobrien@cindex context lines, after match 24753564SobrienPrint @var{num} lines of trailing context after matching lines. 24853564Sobrien 24953564Sobrien@item -B @var{num} 25053564Sobrien@itemx --before-context=@var{num} 25153564Sobrien@opindex -B 25253564Sobrien@opindex --before-context 25353564Sobrien@cindex before context 25453564Sobrien@cindex context lines, before match 25553564SobrienPrint @var{num} lines of leading context before matching lines. 25653564Sobrien 25755360Sobrien@item -C @var{num} 258131554Stjr@itemx --context=@var{num} 25953564Sobrien@opindex -C 26053564Sobrien@opindex --context 26153564Sobrien@cindex context 262131554StjrPrint @var{num} lines of output context. 26353564Sobrien 264131554Stjr@item --colour[=@var{WHEN}] 265131554Stjr@itemx --color[=@var{WHEN}] 266131554Stjr@opindex --colour 267131554Stjr@cindex highlight, color, colour 268131554StjrThe matching string is surrounded by the marker specify in @var{GREP_COLOR}. 269131554Stjr@var{WHEN} may be `never', `always', or `auto'. 27053564Sobrien 27155360Sobrien@item -@var{num} 27253564Sobrien@opindex -NUM 27355360SobrienSame as @samp{--context=@var{num}} lines of leading and trailing 27453564Sobriencontext. However, grep will never print any given line more than once. 27553564Sobrien 27653564Sobrien 27753564Sobrien@item -V 27853564Sobrien@itemx --version 27953564Sobrien@opindex -V 28053564Sobrien@opindex --version 28153564Sobrien@cindex Version, printing 28255360SobrienPrint the version number of @command{grep} to the standard output stream. 28355360SobrienThis version number should be included in all bug reports. 28453564Sobrien 28553564Sobrien@item --help 28653564Sobrien@opindex --help 28753564Sobrien@cindex Usage summary, printing 28853564SobrienPrint a usage message briefly summarizing these command-line options 28953564Sobrienand the bug-reporting address, then exit. 29053564Sobrien 29156230Sru@itemx --binary-files=@var{type} 29256230Sru@opindex --binary-files 29356230Sru@cindex binary files 29456230SruIf the first few bytes of a file indicate that the file contains binary 29556230Srudata, assume that the file is of type @var{type}. By default, 29656230Sru@var{type} is @samp{binary}, and @command{grep} normally outputs either 29756230Srua one-line message saying that a binary file matches, or no message if 29856230Sruthere is no match. If @var{type} is @samp{without-match}, 29956915Sru@command{grep} assumes that a binary file does not match; 30056915Sruthis is equivalent to the @samp{-I} option. If @var{type} 30156230Sruis @samp{text}, @command{grep} processes a binary file as if it were 30256915Srutext; this is equivalent to the @samp{-a} option. 30356230Sru@emph{Warning:} @samp{--binary-files=text} might output binary garbage, 30456230Sruwhich can have nasty side effects if the output is a terminal and if the 30556230Sruterminal driver interprets some of it as commands. 30656230Sru 30753564Sobrien@item -b 30853564Sobrien@itemx --byte-offset 30953564Sobrien@opindex -b 31053564Sobrien@opindex --byte-offset 31153564Sobrien@cindex byte offset 31253564SobrienPrint the byte offset within the input file before each line of output. 31355360SobrienWhen @command{grep} runs on @sc{ms-dos} or MS-Windows, the printed 31455360Sobrienbyte offsets 31553564Sobriendepend on whether the @samp{-u} (@samp{--unix-byte-offsets}) option is 31653564Sobrienused; see below. 31753564Sobrien 318131554Stjr@item -D @var{action} 319131554Stjr@itemx --devices=@var{action} 320131554Stjr@opindex -D 321131554Stjr@opindex --devices 322131554Stjr@cindex device search 323131554StjrIf an input file is a device, FIFO or socket, use @var{action} to process it. 324131554StjrBy default, @var{action} is @samp{read}, which means that devices are 325131554Stjrread just as if they were ordinary files. 326131554StjrIf @var{action} is @samp{skip}, devices, FIFOs and sockets are silently 327131554Stjrskipped. 328131554Stjr 32953564Sobrien@item -d @var{action} 33053564Sobrien@itemx --directories=@var{action} 33155360Sobrien@opindex -d 33253564Sobrien@opindex --directories 33353564Sobrien@cindex directory search 33455360SobrienIf an input file is a directory, use @var{action} to process it. 33555360SobrienBy default, @var{action} is @samp{read}, which means that directories are 33655360Sobrienread just as if they were ordinary files (some operating systems 33755360Sobrienand filesystems disallow this, and will cause @command{grep} to print error 338131554Stjrmessages for every directory or silently skip them). If @var{action} is 339131554Stjr@samp{skip}, directories are silently skipped. If @var{action} is 340131554Stjr@samp{recurse}, @command{grep} reads all files under each directory, 341131554Stjrrecursively; this is equivalent to the @samp{-r} option. 34253564Sobrien 34355360Sobrien@item -H 34455360Sobrien@itemx --with-filename 34555360Sobrien@opindex -H 34655360Sobrien@opindex --With-filename 34755360Sobrien@cindex with filename prefix 34855360SobrienPrint the filename for each match. 34955360Sobrien 35053564Sobrien@item -h 35153564Sobrien@itemx --no-filename 35253564Sobrien@opindex -h 35353564Sobrien@opindex --no-filename 35453564Sobrien@cindex no filename prefix 35553564SobrienSuppress the prefixing of filenames on output when multiple files are searched. 35653564Sobrien 357131554Stjr@item --line-buffered 358131554Stjr@opindex --line-buffered 359131554Stjr@cindex line buffering 360131554StjrSet the line buffering policy, this can be a performance penality. 361131554Stjr 362131554Stjr@item --label=@var{LABEL} 363131554Stjr@opindex --label 364131554Stjr@cindex changing name of standard input 365131554StjrDisplays input actually coming from standard input as input coming from file 366131554Stjr@var{LABEL}. This is especially useful for tools like zgrep, e.g. 367131554Stjr@command{gzip -cd foo.gz |grep --label=foo something} 368131554Stjr 36953564Sobrien@item -L 37053564Sobrien@itemx --files-without-match 37153564Sobrien@opindex -L 37253564Sobrien@opindex --files-without-match 37353564Sobrien@cindex files which don't match 37455360SobrienSuppress normal output; instead print the name of each input 37555360Sobrienfile from which no output would normally have been printed. 37655360SobrienThe scanning of every file will stop on the first match. 37753564Sobrien 37853564Sobrien@item -a 37953564Sobrien@itemx --text 38053564Sobrien@opindex -a 38153564Sobrien@opindex --text 38253564Sobrien@cindex suppress binary data 38353564Sobrien@cindex binary files 38456230SruProcess a binary file as if it were text; this is equivalent to the 38556230Sru@samp{--binary-files=text} option. 38653564Sobrien 38756915Sru@item -I 38856915SruProcess a binary file as if it did not contain matching data; this is 38956915Sruequivalent to the @samp{--binary-files=without-match} option. 39056915Sru 39153564Sobrien@item -w 39253564Sobrien@itemx --word-regexp 39353564Sobrien@opindex -w 39453564Sobrien@opindex --word-regexp 39553564Sobrien@cindex matching whole words 39655360SobrienSelect only those lines containing matches that form 39755360Sobrienwhole words. The test is that the matching substring 39855360Sobrienmust either be at the beginning of the line, or preceded 39953564Sobrienby a non-word constituent character. Similarly, 40053564Sobrienit must be either at the end of the line or followed by 40155360Sobriena non-word constituent character. Word-constituent 40253564Sobriencharacters are letters, digits, and the underscore. 40353564Sobrien 40453564Sobrien@item -r 405131554Stjr@itemx -R 40653564Sobrien@itemx --recursive 40753564Sobrien@opindex -r 40853564Sobrien@opindex --recursive 40953564Sobrien@cindex recursive search 41053564Sobrien@cindex searching directory trees 41153564SobrienFor each directory mentioned in the command line, read and process all 412131554Stjrfiles in that directory, recursively. This is the same as the 413131554Stjr@samp{--directories=recurse} option. 41453564Sobrien 415131554Stjr@item --include=@var{file_pattern} 416131554Stjr@opindex --include 417131554Stjr@cindex include files 418131554Stjr@cindex searching directory trees 419131554StjrWhen processing directories recursively, only files matching @var{file_pattern} 420131554Stjrwill be search. 421131554Stjr 422131554Stjr@item --exclude=@var{file_pattern} 423131554Stjr@opindex --exclude 424131554Stjr@cindex exclude files 425131554Stjr@cindex searching directory trees 426131554StjrWhen processing directories recursively, skip files matching @var{file_pattern}. 427131554Stjr 428131554Stjr@item -m @var{num} 429131554Stjr@itemx --max-count=@var{num} 430131554Stjr@opindex -m 431131554Stjr@opindex --max-count 432131554Stjr@cindex max-count 433131554StjrStop reading a file after @var{num} matching lines. If the input is 434131554Stjrstandard input from a regular file, and @var{num} matching lines are 435131554Stjroutput, @command{grep} ensures that the standard input is positioned to 436131554Stjrjust after the last matching line before exiting, regardless of the 437131554Stjrpresence of trailing context lines. This enables a calling process 438131554Stjrto resume a search. For example, the following shell script makes use 439131554Stjrof it: 440131554Stjr 441131554Stjr@example 442131554Stjrwhile grep -m 1 PATTERN 443131554Stjrdo 444131554Stjr echo xxxx 445131554Stjrdone < FILE 446131554Stjr@end example 447131554Stjr 448131554StjrBut the following probably will not work because a pipe is not a regular 449131554Stjrfile: 450131554Stjr 451131554Stjr@example 452131554Stjr# This probably will not work. 453131554Stjrcat FILE | 454131554Stjrwhile grep -m 1 PATTERN 455131554Stjrdo 456131554Stjr echo xxxx 457131554Stjrdone 458131554Stjr@end example 459131554Stjr 460131554StjrWhen @command{grep} stops after NUM matching lines, it outputs 461131554Stjrany trailing context lines. Since context does not include matching 462131554Stjrlines, @command{grep} will stop when it encounters another matching line. 463131554StjrWhen the @samp{-c} or @samp{--count} option is also used, 464131554Stjr@command{grep} does not output a count greater than @var{num}. 465131554StjrWhen the @samp{-v} or @samp{--invert-match} option is 466131554Stjralso used, @command{grep} stops after outputting @var{num} 467131554Stjrnon-matching lines. 468131554Stjr 46953564Sobrien@item -y 47053564Sobrien@opindex -y 47153564Sobrien@cindex case insensitive search, obsolete option 47253564SobrienObsolete synonym for @samp{-i}. 47353564Sobrien 47453564Sobrien@item -U 47553564Sobrien@itemx --binary 47653564Sobrien@opindex -U 47753564Sobrien@opindex --binary 47853564Sobrien@cindex DOS/Windows binary files 47953564Sobrien@cindex binary files, DOS/Windows 48055360SobrienTreat the file(s) as binary. By default, under @sc{ms-dos} 48155360Sobrienand MS-Windows, @command{grep} guesses the file type by looking 48255360Sobrienat the contents of the first 32kB read from the file. 48355360SobrienIf @command{grep} decides the file is a text file, it strips the 48455360Sobrien@code{CR} characters from the original file contents (to make 48555360Sobrienregular expressions with @code{^} and @code{$} work correctly). 48653564SobrienSpecifying @samp{-U} overrules this guesswork, causing all 48755360Sobrienfiles to be read and passed to the matching mechanism 48855360Sobrienverbatim; if the file is a text file with @code{CR/LF} pairs 48955360Sobrienat the end of each line, this will cause some regular 49055360Sobrienexpressions to fail. This option has no effect on platforms other than 49155360Sobrien@sc{ms-dos} and MS-Windows. 49253564Sobrien 49353564Sobrien@item -u 49453564Sobrien@itemx --unix-byte-offsets 49553564Sobrien@opindex -u 49653564Sobrien@opindex --unix-byte-offsets 49753564Sobrien@cindex DOS byte offsets 49853564Sobrien@cindex byte offsets, on DOS/Windows 49955360SobrienReport Unix-style byte offsets. This switch causes 50055360Sobrien@command{grep} to report byte offsets as if the file were Unix style 50155360Sobrientext file, i.e., the byte offsets ignore the @code{CR} characters which were 50255360Sobrienstripped. This will produce results identical to running @command{grep} on 50355360Sobriena Unix machine. This option has no effect unless @samp{-b} 50455360Sobrienoption is also used; it has no effect on platforms other than @sc{ms-dos} and 50553564SobrienMS-Windows. 50653564Sobrien 50755360Sobrien@item --mmap 50855360Sobrien@opindex --mmap 50955360Sobrien@cindex memory mapped input 51055360SobrienIf possible, use the @code{mmap} system call to read input, instead of 51155360Sobrienthe default @code{read} system call. In some situations, @samp{--mmap} 51255360Sobrienyields better performance. However, @samp{--mmap} can cause undefined 51355360Sobrienbehavior (including core dumps) if an input file shrinks while 51455360Sobrien@command{grep} is operating, or if an I/O error occurs. 51555360Sobrien 51655360Sobrien@item -Z 51755360Sobrien@itemx --null 51855360Sobrien@opindex -Z 51955360Sobrien@opindex --null 52055360Sobrien@cindex zero-terminated file names 52155360SobrienOutput a zero byte (the @sc{ascii} @code{NUL} character) instead of the 52255360Sobriencharacter that normally follows a file name. For example, @samp{grep 52355360Sobrien-lZ} outputs a zero byte after each file name instead of the usual 52455360Sobriennewline. This option makes the output unambiguous, even in the presence 52555360Sobrienof file names containing unusual characters like newlines. This option 52655360Sobriencan be used with commands like @samp{find -print0}, @samp{perl -0}, 52755360Sobrien@samp{sort -z}, and @samp{xargs -0} to process arbitrary file names, 52855360Sobrieneven those that contain newline characters. 52955360Sobrien 53055360Sobrien@item -z 53155360Sobrien@itemx --null-data 53255360Sobrien@opindex -z 53355360Sobrien@opindex --null-data 53455360Sobrien@cindex zero-terminated lines 53555360SobrienTreat the input as a set of lines, each terminated by a zero byte (the 53655360Sobrien@sc{ascii} @code{NUL} character) instead of a newline. Like the @samp{-Z} 53755360Sobrienor @samp{--null} option, this option can be used with commands like 53855360Sobrien@samp{sort -z} to process arbitrary file names. 53955360Sobrien 54053564Sobrien@end table 54153564Sobrien 54255360SobrienSeveral additional options control which variant of the @command{grep} 54353564Sobrienmatching engine is used. @xref{Grep Programs}. 54453564Sobrien 54555360Sobrien@section Environment Variables 54653564Sobrien 54755360SobrienGrep's behavior is affected by the following environment variables. 548131554Stjr 549131554StjrA locale @code{LC_@var{foo}} is specified by examining the three 550131554Stjrenvironment variables @env{LC_ALL}, @env{LC_@var{foo}}, and @env{LANG}, 551131554Stjrin that order. The first of these variables that is set specifies the 552131554Stjrlocale. For example, if @env{LC_ALL} is not set, but @env{LC_MESSAGES} 553131554Stjris set to @samp{pt_BR}, then Brazilian Portuguese is used for the 554131554Stjr@code{LC_MESSAGES} locale. The C locale is used if none of these 555131554Stjrenvironment variables are set, or if the locale catalog is not 556131554Stjrinstalled, or if @command{grep} was not compiled with national language 557131554Stjrsupport (@sc{nls}). 558131554Stjr 55955360Sobrien@cindex environment variables 56055360Sobrien 561131554Stjr@table @env 56255360Sobrien 56355360Sobrien@item GREP_OPTIONS 56455360Sobrien@vindex GREP_OPTIONS 56555360Sobrien@cindex default options environment variable 56655360SobrienThis variable specifies default options to be placed in front of any 56756915Sruexplicit options. For example, if @code{GREP_OPTIONS} is 56856915Sru@samp{--binary-files=without-match --directories=skip}, @command{grep} 56956915Srubehaves as if the two options @samp{--binary-files=without-match} and 57056915Sru@samp{--directories=skip} had been specified before 57155360Sobrienany explicit options. Option specifications are separated by 57255360Sobrienwhitespace. A backslash escapes the next character, so it can be used to 57355360Sobrienspecify an option containing whitespace or a backslash. 57455360Sobrien 575131554Stjr@item GREP_COLOR 576131554Stjr@vindex GREP_COLOR 577131554Stjr@cindex highlight markers 578131554StjrThis variable specifies the surrounding markers use to highlight the matching 579131554Stjrtext. The default is control ascii red. 580131554Stjr 58155360Sobrien@item LC_ALL 582131554Stjr@itemx LC_COLLATE 58355360Sobrien@itemx LANG 58455360Sobrien@vindex LC_ALL 585131554Stjr@vindex LC_COLLATE 58655360Sobrien@vindex LANG 587131554Stjr@cindex character type 58855360Sobrien@cindex national language support 58955360Sobrien@cindex NLS 590131554StjrThese variables specify the @code{LC_COLLATE} locale, which determines 591131554Stjrthe collating sequence used to interpret range expressions like 592131554Stjr@samp{[a-z]}. 59355360Sobrien 59455360Sobrien@item LC_ALL 59555360Sobrien@itemx LC_CTYPE 59655360Sobrien@itemx LANG 59755360Sobrien@vindex LC_ALL 59855360Sobrien@vindex LC_CTYPE 59955360Sobrien@vindex LANG 60055360Sobrien@cindex character type 60155360Sobrien@cindex national language support 60255360Sobrien@cindex NLS 60355360SobrienThese variables specify the @code{LC_CTYPE} locale, which determines the 604131554Stjrtype of characters, e.g., which characters are whitespace. 60555360Sobrien 606131554Stjr@item LC_ALL 607131554Stjr@itemx LC_MESSAGES 608131554Stjr@itemx LANG 609131554Stjr@vindex LC_ALL 610131554Stjr@vindex LC_MESSAGES 611131554Stjr@vindex LANG 612131554Stjr@cindex language of messages 613131554Stjr@cindex message language 614131554Stjr@cindex national language support 615131554Stjr@cindex NLS 616131554Stjr@cindex translation of message language 617131554StjrThese variables specify the @code{LC_MESSAGES} locale, which determines 618131554Stjrthe language that @command{grep} uses for messages. The default C 619131554Stjrlocale uses American English messages. 620131554Stjr 62155360Sobrien@item POSIXLY_CORRECT 62255360Sobrien@vindex POSIXLY_CORRECT 62355360SobrienIf set, @command{grep} behaves as @sc{posix.2} requires; otherwise, 62455360Sobrien@command{grep} behaves more like other @sc{gnu} programs. @sc{posix.2} 62555360Sobrienrequires that options that 62655360Sobrienfollow file names must be treated as file names; by default, such 62755360Sobrienoptions are permuted to the front of the operand list and are treated as 62855360Sobrienoptions. Also, @sc{posix.2} requires that unrecognized options be 62955360Sobriendiagnosed as 63055360Sobrien``illegal'', but since they are not really against the law the default 63155360Sobrienis to diagnose them as ``invalid''. @code{POSIXLY_CORRECT} also 63255360Sobriendisables @code{_@var{N}_GNU_nonoption_argv_flags_}, described below. 63355360Sobrien 63455360Sobrien@item _@var{N}_GNU_nonoption_argv_flags_ 63555360Sobrien@vindex _@var{N}_GNU_nonoption_argv_flags_ 63655360Sobrien(Here @code{@var{N}} is @command{grep}'s numeric process ID.) If the 63755360Sobrien@var{i}th character of this environment variable's value is @samp{1}, do 63855360Sobriennot consider the @var{i}th operand of @command{grep} to be an option, even if 63955360Sobrienit appears to be one. A shell can put this variable in the environment 64055360Sobrienfor each command it runs, specifying which operands are the results of 64155360Sobrienfile name wildcard expansion and therefore should not be treated as 64255360Sobrienoptions. This behavior is available only with the @sc{gnu} C library, and 64355360Sobrienonly when @code{POSIXLY_CORRECT} is not set. 64455360Sobrien 64555360Sobrien@end table 64655360Sobrien 64755360Sobrien@node Diagnostics 64853564Sobrien@chapter Diagnostics 64955360Sobrien 650131554StjrNormally, exit status is 0 if selected lines are found and 1 otherwise. 651131554StjrBut the exit status is 2 if an error occurred, unless the @option{-q} or 652131554Stjr@option{--quiet} or @option{--silent} option is used and a selected line 653131554Stjris found. 65453564Sobrien 65555360Sobrien@node Grep Programs 65655360Sobrien@chapter @command{grep} programs 65753564Sobrien 65855360Sobrien@command{grep} searches the named input files (or standard input if no 65953564Sobrienfiles are named, or the file name @file{-} is given) for lines containing 66055360Sobriena match to the given pattern. By default, @command{grep} prints the 661131554Stjrmatching lines. There are four major variants of @command{grep}, 66255360Sobriencontrolled by the following options. 66353564Sobrien 66453564Sobrien@table @samp 66553564Sobrien 66653564Sobrien@item -G 66753564Sobrien@itemx --basic-regexp 66853564Sobrien@opindex -G 66953564Sobrien@opindex --basic-regexp 67053564Sobrien@cindex matching basic regular expressions 671131554StjrInterpret the pattern as a basic regular expression. This is the default. 67253564Sobrien 67353564Sobrien@item -E 67455360Sobrien@itemx --extended-regexp 67553564Sobrien@opindex -E 67653564Sobrien@opindex --extended-regexp 67753564Sobrien@cindex matching extended regular expressions 678131554StjrInterpret the pattern as an extended regular expression. 67953564Sobrien 68053564Sobrien@item -F 68153564Sobrien@itemx --fixed-strings 68253564Sobrien@opindex -F 68353564Sobrien@opindex --fixed-strings 68453564Sobrien@cindex matching fixed strings 685131554StjrInterpret the pattern as a list of fixed strings, separated 68653564Sobrienby newlines, any of which is to be matched. 68753564Sobrien 688131554Stjr@item -P 689131554Stjr@itemx --perl-regexp 690131554Stjr@opindex -P 691131554Stjr@opindex --perl-regexp 692131554Stjr@cindex matching Perl regular expressions 693131554StjrInterpret the pattern as a Perl regular expression. 694131554Stjr 69553564Sobrien@end table 69653564Sobrien 69753564SobrienIn addition, two variant programs @sc{egrep} and @sc{fgrep} are available. 69855360Sobrien@sc{egrep} is the same as @samp{grep -E}. @sc{fgrep} is the 69953564Sobriensame as @samp{grep -F}. 70053564Sobrien 70155360Sobrien@node Regular Expressions 70253564Sobrien@chapter Regular Expressions 70353564Sobrien@cindex regular expressions 70453564Sobrien 70555360SobrienA @dfn{regular expression} is a pattern that describes a set of strings. 70653564SobrienRegular expressions are constructed analogously to arithmetic expressions, 70755360Sobrienby using various operators to combine smaller expressions. 70855360Sobrien@command{grep} understands two different versions of regular expression 709131554Stjrsyntax: ``basic''(BRE) and ``extended''(ERE). In @sc{gnu} @command{grep}, 710131554Stjrthere is no difference in available functionality using either syntax. 71155360SobrienIn other implementations, basic regular expressions are less powerful. 71255360SobrienThe following description applies to extended regular expressions; 71353564Sobriendifferences for basic regular expressions are summarized afterwards. 71453564Sobrien 71555360SobrienThe fundamental building blocks are the regular expressions that match 71653564Sobriena single character. Most characters, including all letters and digits, 71755360Sobrienare regular expressions that match themselves. Any metacharacter 71853564Sobrienwith special meaning may be quoted by preceding it with a backslash. 71953564Sobrien 720131554StjrA regular expression may be followed by one of several 721131554Stjrrepetition operators: 722131554Stjr 723131554Stjr@table @samp 724131554Stjr 725131554Stjr@item . 726131554Stjr@opindex . 727131554Stjr@cindex dot 728131554Stjr@cindex period 729131554StjrThe period @samp{.} matches any single character. 730131554Stjr 731131554Stjr@item ? 732131554Stjr@opindex ? 733131554Stjr@cindex question mark 734131554Stjr@cindex match sub-expression at most once 735131554StjrThe preceding item is optional and will be matched at most once. 736131554Stjr 737131554Stjr@item * 738131554Stjr@opindex * 739131554Stjr@cindex asterisk 740131554Stjr@cindex match sub-expression zero or more times 741131554StjrThe preceding item will be matched zero or more times. 742131554Stjr 743131554Stjr@item + 744131554Stjr@opindex + 745131554Stjr@cindex plus sign 746131554StjrThe preceding item will be matched one or more times. 747131554Stjr 748131554Stjr@item @{@var{n}@} 749131554Stjr@opindex @{n@} 750131554Stjr@cindex braces, one argument 751131554Stjr@cindex match sub-expression n times 752131554StjrThe preceding item is matched exactly @var{n} times. 753131554Stjr 754131554Stjr@item @{@var{n},@} 755131554Stjr@opindex @{n,@} 756131554Stjr@cindex braces, second argument omitted 757131554Stjr@cindex match sub-expression n or more times 758131554StjrThe preceding item is matched n or more times. 759131554Stjr 760131554Stjr@item @{@var{n},@var{m}@} 761131554Stjr@opindex @{n,m@} 762131554Stjr@cindex braces, two arguments 763131554StjrThe preceding item is matched at least @var{n} times, but not more than 764131554Stjr@var{m} times. 765131554Stjr 766131554Stjr@end table 767131554Stjr 768131554StjrTwo regular expressions may be concatenated; the resulting regular 769131554Stjrexpression matches any string formed by concatenating two substrings 770131554Stjrthat respectively match the concatenated subexpressions. 771131554Stjr 772131554StjrTwo regular expressions may be joined by the infix operator @samp{|}; the 773131554Stjrresulting regular expression matches any string matching either subexpression. 774131554Stjr 775131554StjrRepetition takes precedence over concatenation, which in turn 776131554Stjrtakes precedence over alternation. A whole subexpression may be 777131554Stjrenclosed in parentheses to override these precedence rules. 778131554Stjr 779131554Stjr@section Character Class 780131554Stjr 781131554Stjr@cindex bracket expression 782131554Stjr@cindex character class 783131554StjrA @dfn{bracket expression} is a list of characters enclosed by @samp{[} and 784131554Stjr@samp{]}. It matches any single character in that list; if the first 785131554Stjrcharacter of the list is the caret @samp{^}, then it matches any character 786131554Stjr@strong{not} in the list. For example, the regular expression 787131554Stjr@samp{[0123456789]} matches any single digit. 788131554Stjr 789131554Stjr@cindex range expression 790131554StjrWithin a bracket expression, a @dfn{range expression} consists of two 791131554Stjrcharacters separated by a hyphen. It matches any single character that 792131554Stjrsorts between the two characters, inclusive, using the locale's 793131554Stjrcollating sequence and character set. For example, in the default C 794131554Stjrlocale, @samp{[a-d]} is equivalent to @samp{[abcd]}. Many locales sort 795131554Stjrcharacters in dictionary order, and in these locales @samp{[a-d]} is 796131554Stjrtypically not equivalent to @samp{[abcd]}; it might be equivalent to 797131554Stjr@samp{[aBbCcDd]}, for example. To obtain the traditional interpretation 798131554Stjrof bracket expressions, you can use the C locale by setting the 799131554Stjr@env{LC_ALL} environment variable to the value @samp{C}. 800131554Stjr 801131554StjrFinally, certain named classes of characters are predefined within 802131554Stjrbracket expressions, as follows. 80355360SobrienTheir interpretation depends on the @code{LC_CTYPE} locale; the 804131554Stjrinterpretation below is that of the C locale, which is the default 80555360Sobrienif no @code{LC_CTYPE} locale is specified. 80655360Sobrien 80753564Sobrien@cindex classes of characters 80853564Sobrien@cindex character classes 80953564Sobrien@table @samp 81053564Sobrien 81153564Sobrien@item [:alnum:] 81255360Sobrien@opindex alnum 81355360Sobrien@cindex alphanumeric characters 81456915SruAlphanumeric characters: 81556915Sru@samp{[:alpha:]} and @samp{[:digit:]}. 81653564Sobrien 81753564Sobrien@item [:alpha:] 81853564Sobrien@opindex alpha 81953564Sobrien@cindex alphabetic characters 82056915SruAlphabetic characters: 82156915Sru@samp{[:lower:]} and @samp{[:upper:]}. 82253564Sobrien 82355360Sobrien@item [:blank:] 82455360Sobrien@opindex blank 82555360Sobrien@cindex blank characters 82656915SruBlank characters: 82756915Sruspace and tab. 82855360Sobrien 82953564Sobrien@item [:cntrl:] 83053564Sobrien@opindex cntrl 83153564Sobrien@cindex control characters 83256915SruControl characters. In @sc{ascii}, these characters have octal codes 000 83356915Sruthrough 037, and 177 (@code{DEL}). In other character sets, these are 83456915Sruthe equivalent characters, if any. 83553564Sobrien 83653564Sobrien@item [:digit:] 83753564Sobrien@opindex digit 83853564Sobrien@cindex digit characters 83953564Sobrien@cindex numeric characters 84056915SruDigits: @code{0 1 2 3 4 5 6 7 8 9}. 84153564Sobrien 84253564Sobrien@item [:graph:] 84353564Sobrien@opindex graph 84453564Sobrien@cindex graphic characters 84556915SruGraphical characters: 84656915Sru@samp{[:alnum:]} and @samp{[:punct:]}. 84753564Sobrien 84853564Sobrien@item [:lower:] 84953564Sobrien@opindex lower 85056915Sru@cindex lower-case letters 85156915SruLower-case letters: 85256915Sru@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}. 85353564Sobrien 85453564Sobrien@item [:print:] 85553564Sobrien@opindex print 85653564Sobrien@cindex printable characters 85756915SruPrintable characters: 85856915Sru@samp{[:alnum:]}, @samp{[:punct:]}, and space. 85953564Sobrien 86053564Sobrien@item [:punct:] 86153564Sobrien@opindex punct 86253564Sobrien@cindex punctuation characters 86356915SruPunctuation characters: 86456915Sru@code{!@: " # $ % & ' ( ) * + , - .@: / : ; < = > ?@: @@ [ \ ] ^ _ ` @{ | @} ~}. 86553564Sobrien 86653564Sobrien@item [:space:] 86753564Sobrien@opindex space 86853564Sobrien@cindex space characters 86953564Sobrien@cindex whitespace characters 87056915SruSpace characters: 87156915Srutab, newline, vertical tab, form feed, carriage return, and space. 87253564Sobrien 87353564Sobrien@item [:upper:] 87453564Sobrien@opindex upper 87556915Sru@cindex upper-case letters 87656915SruUpper-case letters: 87756915Sru@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}. 87853564Sobrien 87953564Sobrien@item [:xdigit:] 88053564Sobrien@opindex xdigit 88153564Sobrien@cindex xdigit class 88253564Sobrien@cindex hexadecimal digits 88356915SruHexadecimal digits: 88456915Sru@code{0 1 2 3 4 5 6 7 8 9 A B C D E F a b c d e f}. 88553564Sobrien 88653564Sobrien@end table 88753564SobrienFor example, @samp{[[:alnum:]]} means @samp{[0-9A-Za-z]}, except the latter 888131554Stjrdepends upon the C locale and the @sc{ascii} character 88956915Sruencoding, whereas the former is independent of locale and character set. 89056915Sru(Note that the brackets in these class names are 89155360Sobrienpart of the symbolic names, and must be included in addition to 892131554Stjrthe brackets delimiting the bracket list.) 89353564Sobrien 894131554StjrMost metacharacters lose their special meaning inside lists. 89553564Sobrien 896131554Stjr@table @samp 897131554Stjr@item ] 898131554Stjrends the list if it's not the first list item. So, if you want to make 899131554Stjrthe @samp{]} character a list item, you must put it first. 90053564Sobrien 901131554Stjr@item [. 902131554Stjrrepresents the open collating symbol. 90353564Sobrien 904131554Stjr@item .] 905131554Stjrrepresents the close collating symbol. 90653564Sobrien 907131554Stjr@item [= 908131554Stjrrepresents the open equivalence class. 909131554Stjr 910131554Stjr@item =] 911131554Stjrrepresents the close equivalence class. 912131554Stjr 913131554Stjr@item [: 914131554Stjrrepresents the open character class followed by a valid character class name. 915131554Stjr 916131554Stjr@item :] 917131554Stjrrepresents the close character class followed by a valid character class name. 918131554Stjr 919131554Stjr@item - 920131554Stjrrepresents the range if it's not first or last in a list or the ending point 921131554Stjrof a range. 922131554Stjr 923131554Stjr@item ^ 924131554Stjrrepresents the characters not in the list. If you want to make the @samp{^} 925131554Stjrcharacter a list item, place it anywhere but first. 926131554Stjr 927131554Stjr@end table 928131554Stjr 929131554Stjr@section Backslash Character 930131554Stjr@cindex backslash 931131554Stjr 932131554StjrThe @samp{\} when followed by certain ordinary characters take a special 933131554Stjrmeaning : 934131554Stjr 93553564Sobrien@table @samp 93653564Sobrien 937131554Stjr@item @samp{\b} 938131554StjrMatch the empty string at the edge of a word. 93953564Sobrien 940131554Stjr@item @samp{\B} 941131554StjrMatch the empty string provided it's not at the edge of a word. 94253564Sobrien 943131554Stjr@item @samp{\<} 944131554StjrMatch the empty string at the beginning of word. 94553564Sobrien 946131554Stjr@item @samp{\>} 947131554StjrMatch the empty string at the end of word. 94853564Sobrien 949131554Stjr@item @samp{\w} 950131554StjrMatch word constituent, it is a synonym for @samp{[[:alnum:]]}. 95153564Sobrien 952131554Stjr@item @samp{\W} 953131554StjrMatch non word constituent, it is a synonym for @samp{[^[:alnum:]]}. 95453564Sobrien 95553564Sobrien@end table 95653564Sobrien 957131554StjrFor example , @samp{\brat\b} matches the separate word @samp{rat}, 958131554Stjr@samp{c\Brat\Be} matches @samp{crate}, but @samp{dirty \Brat} doesn't 959131554Stjrmatch @samp{dirty rat}. 96053564Sobrien 961131554Stjr@section Anchoring 962131554Stjr@cindex anchoring 96353564Sobrien 964131554StjrThe caret @samp{^} and the dollar sign @samp{$} are metacharacters that 965131554Stjrrespectively match the empty string at the beginning and end of a line. 96653564Sobrien 967131554Stjr@section Back-reference 968131554Stjr@cindex back-reference 96953564Sobrien 970131554StjrThe back-reference @samp{\@var{n}}, where @var{n} is a single digit, matches 971131554Stjrthe substring previously matched by the @var{n}th parenthesized subexpression 972131554Stjrof the regular expression. For example, @samp{(a)\1} matches @samp{aa}. 973131554StjrWhen use with alternation if the group does not participate in the match, then 974131554Stjrthe back-reference makes the whole match fail. For example, @samp{a(.)|b\1} 975131554Stjrwill not match @samp{ba}. When multiple regular expressions are given with 976131554Stjr@samp{-e} or from a file @samp{-f file}, the back-referecences are local to 977131554Stjreach expression. 978131554Stjr 979131554Stjr@section Basic vs Extended 98053564Sobrien@cindex basic regular expressions 981131554Stjr 98253564SobrienIn basic regular expressions the metacharacters @samp{?}, @samp{+}, 98353564Sobrien@samp{@{}, @samp{|}, @samp{(}, and @samp{)} lose their special meaning; 98453564Sobrieninstead use the backslashed versions @samp{\?}, @samp{\+}, @samp{\@{}, 98553564Sobrien@samp{\|}, @samp{\(}, and @samp{\)}. 98653564Sobrien 98755360Sobrien@cindex interval specifications 98855360SobrienTraditional @command{egrep} did not support the @samp{@{} metacharacter, 98955360Sobrienand some @command{egrep} implementations support @samp{\@{} instead, so 99055360Sobrienportable scripts should avoid @samp{@{} in @samp{egrep} patterns and 99155360Sobrienshould use @samp{[@{]} to match a literal @samp{@{}. 99253564Sobrien 99355360Sobrien@sc{gnu} @command{egrep} attempts to support traditional usage by 99455360Sobrienassuming that @samp{@{} is not special if it would be the start of an 99555360Sobrieninvalid interval specification. For example, the shell command 99655360Sobrien@samp{egrep '@{1'} searches for the two-character string @samp{@{1} 99755360Sobrieninstead of reporting a syntax error in the regular expression. 99855360Sobrien@sc{posix.2} allows this behavior as an extension, but portable scripts 99955360Sobrienshould avoid it. 100053564Sobrien 100155360Sobrien@node Usage 100255360Sobrien@chapter Usage 100355360Sobrien 100455360Sobrien@cindex Usage, examples 100555360SobrienHere is an example shell command that invokes @sc{gnu} @command{grep}: 100655360Sobrien 100755360Sobrien@example 100855360Sobriengrep -i 'hello.*world' menu.h main.c 100955360Sobrien@end example 101055360Sobrien 101155360Sobrien@noindent 101255360SobrienThis lists all lines in the files @file{menu.h} and @file{main.c} that 101355360Sobriencontain the string @samp{hello} followed by the string @samp{world}; 101455360Sobrienthis is because @samp{.*} matches zero or more characters within a line. 101555360Sobrien@xref{Regular Expressions}. The @samp{-i} option causes @command{grep} 101655360Sobriento ignore case, causing it to match the line @samp{Hello, world!}, which 101755360Sobrienit would not otherwise match. @xref{Invoking}, for more details about 101855360Sobrienhow to invoke @command{grep}. 101955360Sobrien 102055360Sobrien@cindex Using @command{grep}, Q&A 102155360Sobrien@cindex FAQ about @command{grep} usage 102255360SobrienHere are some common questions and answers about @command{grep} usage. 102355360Sobrien 102455360Sobrien@enumerate 102555360Sobrien 102655360Sobrien@item 102755360SobrienHow can I list just the names of matching files? 102855360Sobrien 102955360Sobrien@example 103055360Sobriengrep -l 'main' *.c 1031131554Stjr@end example 103255360Sobrien 103355360Sobrien@noindent 103455360Sobrienlists the names of all C files in the current directory whose contents 103555360Sobrienmention @samp{main}. 103655360Sobrien 103755360Sobrien@item 103855360SobrienHow do I search directories recursively? 103955360Sobrien 104055360Sobrien@example 104155360Sobriengrep -r 'hello' /home/gigi 104255360Sobrien@end example 104355360Sobrien 104455360Sobrien@noindent 104555360Sobriensearches for @samp{hello} in all files under the directory 104655360Sobrien@file{/home/gigi}. For more control of which files are searched, use 104755360Sobrien@command{find}, @command{grep} and @command{xargs}. For example, 104855360Sobrienthe following command searches only C files: 104955360Sobrien 105055360Sobrien@smallexample 105155360Sobrienfind /home/gigi -name '*.c' -print | xargs grep 'hello' /dev/null 105255360Sobrien@end smallexample 105355360Sobrien 1054131554StjrThis differs from the command: 1055131554Stjr 1056131554Stjr@example 1057131554Stjrgrep -r 'hello' *.c 1058131554Stjr@end example 1059131554Stjr 1060131554Stjrwhich merely looks for @samp{hello} in all files in the current 1061131554Stjrdirectory whose names end in @samp{.c}. Here the @option{-r} is 1062131554Stjrprobably unnecessary, as recursion occurs only in the unlikely event 1063131554Stjrthat one of @samp{.c} files is a directory. 1064131554Stjr 106555360Sobrien@item 106655360SobrienWhat if a pattern has a leading @samp{-}? 106755360Sobrien 106855360Sobrien@example 106955360Sobriengrep -e '--cut here--' * 1070131554Stjr@end example 107155360Sobrien 107255360Sobrien@noindent 107355360Sobriensearches for all lines matching @samp{--cut here--}. Without @samp{-e}, 107455360Sobrien@command{grep} would attempt to parse @samp{--cut here--} as a list of 107555360Sobrienoptions. 107655360Sobrien 107755360Sobrien@item 107855360SobrienSuppose I want to search for a whole word, not a part of a word? 107955360Sobrien 108055360Sobrien@example 108155360Sobriengrep -w 'hello' * 108255360Sobrien@end example 108355360Sobrien 108455360Sobrien@noindent 108555360Sobriensearches only for instances of @samp{hello} that are entire words; it 108655360Sobriendoes not match @samp{Othello}. For more control, use @samp{\<} and 108755360Sobrien@samp{\>} to match the start and end of words. For example: 108855360Sobrien 108955360Sobrien@example 109055360Sobriengrep 'hello\>' * 109155360Sobrien@end example 109255360Sobrien 109355360Sobrien@noindent 109455360Sobriensearches only for words ending in @samp{hello}, so it matches the word 109555360Sobrien@samp{Othello}. 109655360Sobrien 109755360Sobrien@item 109855360SobrienHow do I output context around the matching lines? 109955360Sobrien 110055360Sobrien@example 110155360Sobriengrep -C 2 'hello' * 110255360Sobrien@end example 110355360Sobrien 110455360Sobrien@noindent 110555360Sobrienprints two lines of context around each matching line. 110655360Sobrien 110755360Sobrien@item 110855360SobrienHow do I force grep to print the name of the file? 110955360Sobrien 111055360SobrienAppend @file{/dev/null}: 111155360Sobrien 111255360Sobrien@example 111355360Sobriengrep 'eli' /etc/passwd /dev/null 111455360Sobrien@end example 111555360Sobrien 1116131554Stjrgets you: 1117131554Stjr 1118131554Stjr@smallexample 1119131554Stjr/etc/passwd:eli:DNGUTF58.IMe.:98:11:Eli Smith:/home/do/eli:/bin/bash 1120131554Stjr@end smallexample 1121131554Stjr 112255360Sobrien@item 112355360SobrienWhy do people use strange regular expressions on @command{ps} output? 112455360Sobrien 112555360Sobrien@example 112655360Sobrienps -ef | grep '[c]ron' 112755360Sobrien@end example 112855360Sobrien 112955360SobrienIf the pattern had been written without the square brackets, it would 113055360Sobrienhave matched not only the @command{ps} output line for @command{cron}, 113155360Sobrienbut also the @command{ps} output line for @command{grep}. 1132131554StjrNote that some platforms @command{ps} limit the ouput to the width 1133131554Stjrof the screen, grep does not have any limit on the length of a line 1134131554Stjrexcept the available memory. 113555360Sobrien 113655360Sobrien@item 113755360SobrienWhy does @command{grep} report ``Binary file matches''? 113855360Sobrien 113955360SobrienIf @command{grep} listed all matching ``lines'' from a binary file, it 114055360Sobrienwould probably generate output that is not useful, and it might even 114155360Sobrienmuck up your display. So @sc{gnu} @command{grep} suppresses output from 114255360Sobrienfiles that appear to be binary files. To force @sc{gnu} @command{grep} 114355360Sobriento output lines even from files that appear to be binary, use the 114456915Sru@samp{-a} or @samp{--binary-files=text} option. To eliminate the 114556915Sru``Binary file matches'' messages, use the @samp{-I} or 114656915Sru@samp{--binary-files=without-match} option. 114755360Sobrien 114855360Sobrien@item 114955360SobrienWhy doesn't @samp{grep -lv} print nonmatching file names? 115055360Sobrien 115155360Sobrien@samp{grep -lv} lists the names of all files containing one or more 115255360Sobrienlines that do not match. To list the names of all files that contain no 115355360Sobrienmatching lines, use the @samp{-L} or @samp{--files-without-match} 115455360Sobrienoption. 115555360Sobrien 115655360Sobrien@item 115755360SobrienI can do @sc{or} with @samp{|}, but what about @sc{and}? 115855360Sobrien 115955360Sobrien@example 116055360Sobriengrep 'paul' /etc/motd | grep 'franc,ois' 116155360Sobrien@end example 116255360Sobrien 116355360Sobrien@noindent 116455360Sobrienfinds all lines that contain both @samp{paul} and @samp{franc,ois}. 116555360Sobrien 116655360Sobrien@item 116755360SobrienHow can I search in both standard input and in files? 116855360Sobrien 116955360SobrienUse the special file name @samp{-}: 117055360Sobrien 117155360Sobrien@example 117255360Sobriencat /etc/passwd | grep 'alain' - /etc/motd 117355360Sobrien@end example 1174131554Stjr 1175131554Stjr@item 1176131554Stjr@cindex palindromes 1177131554StjrHow to express palindromes in a regular expression? 1178131554Stjr 1179131554StjrIt can be done by using the back referecences, for example a palindrome 1180131554Stjrof 4 chararcters can be written in BRE. 1181131554Stjr 1182131554Stjr@example 1183131554Stjrgrep -w -e '\(.\)\(.\).\2\1' file 1184131554Stjr@end example 1185131554Stjr 1186131554StjrIt matches the word "radar" or "civic". 1187131554Stjr 1188131554StjrGuglielmo Bondioni proposed a single RE that finds all the palindromes up to 19 1189131554Stjrcharacters long. 1190131554Stjr 1191131554Stjr@example 1192131554Stjregrep -e '^(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?).?\9\8\7\6\5\4\3\2\1$' file 1193131554Stjr@end example 1194131554Stjr 1195131554StjrNote this is done by using GNU ERE extensions, it might not be portable on 1196131554Stjrother greps. 1197131554Stjr 1198131554Stjr@item 1199131554StjrWhy are my expressions whith the vertical bar fail? 1200131554Stjr 1201131554Stjr@example 1202131554Stjr/bin/echo "ba" | egrep '(a)\1|(b)\1' 1203131554Stjr@end example 1204131554Stjr 1205131554StjrThe first alternate branch fails then the first group was not in the match 1206131554Stjrthis will make the second alternate branch fails. For example, "aaba" will 1207131554Stjrmatch, the first group participate in the match and can be reuse in the 1208131554Stjrsecond branch. 1209131554Stjr 1210131554Stjr@item 1211131554StjrWhat do @command{grep, fgrep, egrep} stand for ? 1212131554Stjr 1213131554Stjrgrep comes from the way line editing was done on Unix. For example, 1214131554Stjr@command{ed} uses this syntax to print a list of matching lines on the screen. 1215131554Stjr 1216131554Stjr@example 1217131554Stjrglobal/regular expression/print 1218131554Stjrg/re/p 1219131554Stjr@end example 1220131554Stjr 1221131554Stjr@command{fgrep} stands for Fixed @command{grep}, @command{egrep} Extended 1222131554Stjr@command{grep}. 1223131554Stjr 122455360Sobrien@end enumerate 122555360Sobrien 1226131554Stjr@node Reporting Bugs, Copying, Usage, Top 122753564Sobrien@chapter Reporting bugs 122853564Sobrien 122953564Sobrien@cindex Bugs, reporting 123053564SobrienEmail bug reports to @email{bug-gnu-utils@@gnu.org}. 123153564SobrienBe sure to include the word ``grep'' somewhere in the ``Subject:'' field. 123253564Sobrien 1233131554StjrLarge repetition counts in the @samp{@{n,m@}} construct may cause 123455360Sobrien@command{grep} to use lots of memory. In addition, certain other 123555360Sobrienobscure regular expressions require exponential time and 123653564Sobrienspace, and may cause grep to run out of memory. 1237131554StjrBack-references are very slow, and may require exponential time. 123853564Sobrien 1239131554Stjr@node Copying, GNU General Public License, Reporting Bugs, Top 1240131554Stjr@chapter Copying 1241131554Stjr@cindex Copying 1242131554StjrGNU grep is licensed under the GNU GPL, which makes it @dfn{free 1243131554Stjrsoftware}. 1244131554Stjr 1245131554StjrPlease note that ``free'' in ``free software'' refers to liberty, not 1246131554Stjrprice. As some GNU project advocates like to point out, think of ``free 1247131554Stjrspeech'' rather than ``free beer''. The exact and legally binding 1248131554Stjrdistribution terms are spelled out below; in short, you have the right 1249131554Stjr(freedom) to run and change grep and distribute it to other people, and 1250131554Stjreven---if you want---charge money for doing either. The important 1251131554Stjrrestriction is that you have to grant your recipients the same rights 1252131554Stjrand impose the same restrictions. 1253131554Stjr 1254131554StjrThis method of licensing software is also known as @dfn{open source} 1255131554Stjrbecause, among other things, it makes sure that all recipients will 1256131554Stjrreceive the source code along with the program, and be able to improve 1257131554Stjrit. The GNU project prefers the term ``free software'' for reasons 1258131554Stjroutlined at 1259131554Stjr@url{http://www.gnu.org/philosophy/free-software-for-freedom.html}. 1260131554Stjr 1261131554StjrThe exact license terms are defined by this paragraph and the GNU 1262131554StjrGeneral Public License it refers to: 1263131554Stjr 1264131554Stjr@quotation 1265131554StjrGNU grep is free software; you can redistribute it and/or modify it 1266131554Stjrunder the terms of the GNU General Public License as published by the 1267131554StjrFree Software Foundation; either version 2 of the License, or (at your 1268131554Stjroption) any later version. 1269131554Stjr 1270131554StjrGNU grep is distributed in the hope that it will be useful, but WITHOUT 1271131554StjrANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1272131554StjrFITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1273131554Stjrfor more details. 1274131554Stjr 1275131554StjrA copy of the GNU General Public License is included as part of this 1276131554Stjrmanual; if you did not receive it, write to the Free Software 1277131554StjrFoundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 1278131554Stjr@end quotation 1279131554Stjr 1280131554StjrIn addition to this, this manual is free in the same sense: 1281131554Stjr 1282131554Stjr@quotation 1283131554StjrPermission is granted to copy, distribute and/or modify this document 1284131554Stjrunder the terms of the GNU Free Documentation License, Version 1.1 or 1285131554Stjrany later version published by the Free Software Foundation; with the 1286131554StjrInvariant Sections being ``GNU General Public License'' and ``GNU Free 1287131554StjrDocumentation License'', with no Front-Cover Texts, and with no 1288131554StjrBack-Cover Texts. A copy of the license is included in the section 1289131554Stjrentitled ``GNU Free Documentation License''. 1290131554Stjr@end quotation 1291131554Stjr 1292131554Stjr@c #### Maybe we should wrap these licenses in ifinfo? Stallman says 1293131554Stjr@c that the GFDL needs to be present in the manual, and to me it would 1294131554Stjr@c suck to include the license for the manual and not the license for 1295131554Stjr@c the program. 1296131554Stjr 1297131554StjrThe full texts of the GNU General Public License and of the GNU Free 1298131554StjrDocumentation License are available below. 1299131554Stjr 1300131554Stjr@menu 1301131554Stjr* GNU General Public License:: GNU GPL 1302131554Stjr* GNU Free Documentation License:: GNU FDL 1303131554Stjr@end menu 1304131554Stjr 1305131554Stjr@node GNU General Public License, GNU Free Documentation License, Copying, Copying 1306131554Stjr@section GNU General Public License 1307131554Stjr@center Version 2, June 1991 1308131554Stjr@cindex GPL, GNU General Public License 1309131554Stjr 1310131554Stjr@display 1311131554StjrCopyright @copyright{} 1989, 1991 Free Software Foundation, Inc. 1312131554Stjr675 Mass Ave, Cambridge, MA 02139, USA 1313131554Stjr 1314131554StjrEveryone is permitted to copy and distribute verbatim copies 1315131554Stjrof this license document, but changing it is not allowed. 1316131554Stjr@end display 1317131554Stjr 1318131554Stjr@unnumberedsec Preamble 1319131554Stjr 1320131554Stjr The licenses for most software are designed to take away your 1321131554Stjrfreedom to share and change it. By contrast, the GNU General Public 1322131554StjrLicense is intended to guarantee your freedom to share and change free 1323131554Stjrsoftware---to make sure the software is free for all its users. This 1324131554StjrGeneral Public License applies to most of the Free Software 1325131554StjrFoundation's software and to any other program whose authors commit to 1326131554Stjrusing it. (Some other Free Software Foundation software is covered by 1327131554Stjrthe GNU Library General Public License instead.) You can apply it to 1328131554Stjryour programs, too. 1329131554Stjr 1330131554Stjr When we speak of free software, we are referring to freedom, not 1331131554Stjrprice. Our General Public Licenses are designed to make sure that you 1332131554Stjrhave the freedom to distribute copies of free software (and charge for 1333131554Stjrthis service if you wish), that you receive source code or can get it 1334131554Stjrif you want it, that you can change the software or use pieces of it 1335131554Stjrin new free programs; and that you know you can do these things. 1336131554Stjr 1337131554Stjr To protect your rights, we need to make restrictions that forbid 1338131554Stjranyone to deny you these rights or to ask you to surrender the rights. 1339131554StjrThese restrictions translate to certain responsibilities for you if you 1340131554Stjrdistribute copies of the software, or if you modify it. 1341131554Stjr 1342131554Stjr For example, if you distribute copies of such a program, whether 1343131554Stjrgratis or for a fee, you must give the recipients all the rights that 1344131554Stjryou have. You must make sure that they, too, receive or can get the 1345131554Stjrsource code. And you must show them these terms so they know their 1346131554Stjrrights. 1347131554Stjr 1348131554Stjr We protect your rights with two steps: (1) copyright the software, and 1349131554Stjr(2) offer you this license which gives you legal permission to copy, 1350131554Stjrdistribute and/or modify the software. 1351131554Stjr 1352131554Stjr Also, for each author's protection and ours, we want to make certain 1353131554Stjrthat everyone understands that there is no warranty for this free 1354131554Stjrsoftware. If the software is modified by someone else and passed on, we 1355131554Stjrwant its recipients to know that what they have is not the original, so 1356131554Stjrthat any problems introduced by others will not reflect on the original 1357131554Stjrauthors' reputations. 1358131554Stjr 1359131554Stjr Finally, any free program is threatened constantly by software 1360131554Stjrpatents. We wish to avoid the danger that redistributors of a free 1361131554Stjrprogram will individually obtain patent licenses, in effect making the 1362131554Stjrprogram proprietary. To prevent this, we have made it clear that any 1363131554Stjrpatent must be licensed for everyone's free use or not licensed at all. 1364131554Stjr 1365131554Stjr The precise terms and conditions for copying, distribution and 1366131554Stjrmodification follow. 1367131554Stjr 1368131554Stjr@iftex 1369131554Stjr@unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 1370131554Stjr@end iftex 1371131554Stjr@ifinfo 1372131554Stjr@center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 1373131554Stjr@end ifinfo 1374131554Stjr 1375131554Stjr@enumerate 1376131554Stjr@item 1377131554StjrThis License applies to any program or other work which contains 1378131554Stjra notice placed by the copyright holder saying it may be distributed 1379131554Stjrunder the terms of this General Public License. The ``Program'', below, 1380131554Stjrrefers to any such program or work, and a ``work based on the Program'' 1381131554Stjrmeans either the Program or any derivative work under copyright law: 1382131554Stjrthat is to say, a work containing the Program or a portion of it, 1383131554Stjreither verbatim or with modifications and/or translated into another 1384131554Stjrlanguage. (Hereinafter, translation is included without limitation in 1385131554Stjrthe term ``modification''.) Each licensee is addressed as ``you''. 1386131554Stjr 1387131554StjrActivities other than copying, distribution and modification are not 1388131554Stjrcovered by this License; they are outside its scope. The act of 1389131554Stjrrunning the Program is not restricted, and the output from the Program 1390131554Stjris covered only if its contents constitute a work based on the 1391131554StjrProgram (independent of having been made by running the Program). 1392131554StjrWhether that is true depends on what the Program does. 1393131554Stjr 1394131554Stjr@item 1395131554StjrYou may copy and distribute verbatim copies of the Program's 1396131554Stjrsource code as you receive it, in any medium, provided that you 1397131554Stjrconspicuously and appropriately publish on each copy an appropriate 1398131554Stjrcopyright notice and disclaimer of warranty; keep intact all the 1399131554Stjrnotices that refer to this License and to the absence of any warranty; 1400131554Stjrand give any other recipients of the Program a copy of this License 1401131554Stjralong with the Program. 1402131554Stjr 1403131554StjrYou may charge a fee for the physical act of transferring a copy, and 1404131554Stjryou may at your option offer warranty protection in exchange for a fee. 1405131554Stjr 1406131554Stjr@item 1407131554StjrYou may modify your copy or copies of the Program or any portion 1408131554Stjrof it, thus forming a work based on the Program, and copy and 1409131554Stjrdistribute such modifications or work under the terms of Section 1 1410131554Stjrabove, provided that you also meet all of these conditions: 1411131554Stjr 1412131554Stjr@enumerate a 1413131554Stjr@item 1414131554StjrYou must cause the modified files to carry prominent notices 1415131554Stjrstating that you changed the files and the date of any change. 1416131554Stjr 1417131554Stjr@item 1418131554StjrYou must cause any work that you distribute or publish, that in 1419131554Stjrwhole or in part contains or is derived from the Program or any 1420131554Stjrpart thereof, to be licensed as a whole at no charge to all third 1421131554Stjrparties under the terms of this License. 1422131554Stjr 1423131554Stjr@item 1424131554StjrIf the modified program normally reads commands interactively 1425131554Stjrwhen run, you must cause it, when started running for such 1426131554Stjrinteractive use in the most ordinary way, to print or display an 1427131554Stjrannouncement including an appropriate copyright notice and a 1428131554Stjrnotice that there is no warranty (or else, saying that you provide 1429131554Stjra warranty) and that users may redistribute the program under 1430131554Stjrthese conditions, and telling the user how to view a copy of this 1431131554StjrLicense. (Exception: if the Program itself is interactive but 1432131554Stjrdoes not normally print such an announcement, your work based on 1433131554Stjrthe Program is not required to print an announcement.) 1434131554Stjr@end enumerate 1435131554Stjr 1436131554StjrThese requirements apply to the modified work as a whole. If 1437131554Stjridentifiable sections of that work are not derived from the Program, 1438131554Stjrand can be reasonably considered independent and separate works in 1439131554Stjrthemselves, then this License, and its terms, do not apply to those 1440131554Stjrsections when you distribute them as separate works. But when you 1441131554Stjrdistribute the same sections as part of a whole which is a work based 1442131554Stjron the Program, the distribution of the whole must be on the terms of 1443131554Stjrthis License, whose permissions for other licensees extend to the 1444131554Stjrentire whole, and thus to each and every part regardless of who wrote it. 1445131554Stjr 1446131554StjrThus, it is not the intent of this section to claim rights or contest 1447131554Stjryour rights to work written entirely by you; rather, the intent is to 1448131554Stjrexercise the right to control the distribution of derivative or 1449131554Stjrcollective works based on the Program. 1450131554Stjr 1451131554StjrIn addition, mere aggregation of another work not based on the Program 1452131554Stjrwith the Program (or with a work based on the Program) on a volume of 1453131554Stjra storage or distribution medium does not bring the other work under 1454131554Stjrthe scope of this License. 1455131554Stjr 1456131554Stjr@item 1457131554StjrYou may copy and distribute the Program (or a work based on it, 1458131554Stjrunder Section 2) in object code or executable form under the terms of 1459131554StjrSections 1 and 2 above provided that you also do one of the following: 1460131554Stjr 1461131554Stjr@enumerate a 1462131554Stjr@item 1463131554StjrAccompany it with the complete corresponding machine-readable 1464131554Stjrsource code, which must be distributed under the terms of Sections 1465131554Stjr1 and 2 above on a medium customarily used for software interchange; or, 1466131554Stjr 1467131554Stjr@item 1468131554StjrAccompany it with a written offer, valid for at least three 1469131554Stjryears, to give any third party, for a charge no more than your 1470131554Stjrcost of physically performing source distribution, a complete 1471131554Stjrmachine-readable copy of the corresponding source code, to be 1472131554Stjrdistributed under the terms of Sections 1 and 2 above on a medium 1473131554Stjrcustomarily used for software interchange; or, 1474131554Stjr 1475131554Stjr@item 1476131554StjrAccompany it with the information you received as to the offer 1477131554Stjrto distribute corresponding source code. (This alternative is 1478131554Stjrallowed only for noncommercial distribution and only if you 1479131554Stjrreceived the program in object code or executable form with such 1480131554Stjran offer, in accord with Subsection b above.) 1481131554Stjr@end enumerate 1482131554Stjr 1483131554StjrThe source code for a work means the preferred form of the work for 1484131554Stjrmaking modifications to it. For an executable work, complete source 1485131554Stjrcode means all the source code for all modules it contains, plus any 1486131554Stjrassociated interface definition files, plus the scripts used to 1487131554Stjrcontrol compilation and installation of the executable. However, as a 1488131554Stjrspecial exception, the source code distributed need not include 1489131554Stjranything that is normally distributed (in either source or binary 1490131554Stjrform) with the major components (compiler, kernel, and so on) of the 1491131554Stjroperating system on which the executable runs, unless that component 1492131554Stjritself accompanies the executable. 1493131554Stjr 1494131554StjrIf distribution of executable or object code is made by offering 1495131554Stjraccess to copy from a designated place, then offering equivalent 1496131554Stjraccess to copy the source code from the same place counts as 1497131554Stjrdistribution of the source code, even though third parties are not 1498131554Stjrcompelled to copy the source along with the object code. 1499131554Stjr 1500131554Stjr@item 1501131554StjrYou may not copy, modify, sublicense, or distribute the Program 1502131554Stjrexcept as expressly provided under this License. Any attempt 1503131554Stjrotherwise to copy, modify, sublicense or distribute the Program is 1504131554Stjrvoid, and will automatically terminate your rights under this License. 1505131554StjrHowever, parties who have received copies, or rights, from you under 1506131554Stjrthis License will not have their licenses terminated so long as such 1507131554Stjrparties remain in full compliance. 1508131554Stjr 1509131554Stjr@item 1510131554StjrYou are not required to accept this License, since you have not 1511131554Stjrsigned it. However, nothing else grants you permission to modify or 1512131554Stjrdistribute the Program or its derivative works. These actions are 1513131554Stjrprohibited by law if you do not accept this License. Therefore, by 1514131554Stjrmodifying or distributing the Program (or any work based on the 1515131554StjrProgram), you indicate your acceptance of this License to do so, and 1516131554Stjrall its terms and conditions for copying, distributing or modifying 1517131554Stjrthe Program or works based on it. 1518131554Stjr 1519131554Stjr@item 1520131554StjrEach time you redistribute the Program (or any work based on the 1521131554StjrProgram), the recipient automatically receives a license from the 1522131554Stjroriginal licensor to copy, distribute or modify the Program subject to 1523131554Stjrthese terms and conditions. You may not impose any further 1524131554Stjrrestrictions on the recipients' exercise of the rights granted herein. 1525131554StjrYou are not responsible for enforcing compliance by third parties to 1526131554Stjrthis License. 1527131554Stjr 1528131554Stjr@item 1529131554StjrIf, as a consequence of a court judgment or allegation of patent 1530131554Stjrinfringement or for any other reason (not limited to patent issues), 1531131554Stjrconditions are imposed on you (whether by court order, agreement or 1532131554Stjrotherwise) that contradict the conditions of this License, they do not 1533131554Stjrexcuse you from the conditions of this License. If you cannot 1534131554Stjrdistribute so as to satisfy simultaneously your obligations under this 1535131554StjrLicense and any other pertinent obligations, then as a consequence you 1536131554Stjrmay not distribute the Program at all. For example, if a patent 1537131554Stjrlicense would not permit royalty-free redistribution of the Program by 1538131554Stjrall those who receive copies directly or indirectly through you, then 1539131554Stjrthe only way you could satisfy both it and this License would be to 1540131554Stjrrefrain entirely from distribution of the Program. 1541131554Stjr 1542131554StjrIf any portion of this section is held invalid or unenforceable under 1543131554Stjrany particular circumstance, the balance of the section is intended to 1544131554Stjrapply and the section as a whole is intended to apply in other 1545131554Stjrcircumstances. 1546131554Stjr 1547131554StjrIt is not the purpose of this section to induce you to infringe any 1548131554Stjrpatents or other property right claims or to contest validity of any 1549131554Stjrsuch claims; this section has the sole purpose of protecting the 1550131554Stjrintegrity of the free software distribution system, which is 1551131554Stjrimplemented by public license practices. Many people have made 1552131554Stjrgenerous contributions to the wide range of software distributed 1553131554Stjrthrough that system in reliance on consistent application of that 1554131554Stjrsystem; it is up to the author/donor to decide if he or she is willing 1555131554Stjrto distribute software through any other system and a licensee cannot 1556131554Stjrimpose that choice. 1557131554Stjr 1558131554StjrThis section is intended to make thoroughly clear what is believed to 1559131554Stjrbe a consequence of the rest of this License. 1560131554Stjr 1561131554Stjr@item 1562131554StjrIf the distribution and/or use of the Program is restricted in 1563131554Stjrcertain countries either by patents or by copyrighted interfaces, the 1564131554Stjroriginal copyright holder who places the Program under this License 1565131554Stjrmay add an explicit geographical distribution limitation excluding 1566131554Stjrthose countries, so that distribution is permitted only in or among 1567131554Stjrcountries not thus excluded. In such case, this License incorporates 1568131554Stjrthe limitation as if written in the body of this License. 1569131554Stjr 1570131554Stjr@item 1571131554StjrThe Free Software Foundation may publish revised and/or new versions 1572131554Stjrof the General Public License from time to time. Such new versions will 1573131554Stjrbe similar in spirit to the present version, but may differ in detail to 1574131554Stjraddress new problems or concerns. 1575131554Stjr 1576131554StjrEach version is given a distinguishing version number. If the Program 1577131554Stjrspecifies a version number of this License which applies to it and ``any 1578131554Stjrlater version'', you have the option of following the terms and conditions 1579131554Stjreither of that version or of any later version published by the Free 1580131554StjrSoftware Foundation. If the Program does not specify a version number of 1581131554Stjrthis License, you may choose any version ever published by the Free Software 1582131554StjrFoundation. 1583131554Stjr 1584131554Stjr@item 1585131554StjrIf you wish to incorporate parts of the Program into other free 1586131554Stjrprograms whose distribution conditions are different, write to the author 1587131554Stjrto ask for permission. For software which is copyrighted by the Free 1588131554StjrSoftware Foundation, write to the Free Software Foundation; we sometimes 1589131554Stjrmake exceptions for this. Our decision will be guided by the two goals 1590131554Stjrof preserving the free status of all derivatives of our free software and 1591131554Stjrof promoting the sharing and reuse of software generally. 1592131554Stjr 1593131554Stjr@iftex 1594131554Stjr@heading NO WARRANTY 1595131554Stjr@end iftex 1596131554Stjr@ifinfo 1597131554Stjr@center NO WARRANTY 1598131554Stjr@end ifinfo 1599131554Stjr@cindex no warranty 1600131554Stjr 1601131554Stjr@item 1602131554StjrBECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 1603131554StjrFOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 1604131554StjrOTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 1605131554StjrPROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 1606131554StjrOR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 1607131554StjrMERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 1608131554StjrTO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 1609131554StjrPROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 1610131554StjrREPAIR OR CORRECTION. 1611131554Stjr 1612131554Stjr@item 1613131554StjrIN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 1614131554StjrWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 1615131554StjrREDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 1616131554StjrINCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 1617131554StjrOUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 1618131554StjrTO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 1619131554StjrYOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 1620131554StjrPROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 1621131554StjrPOSSIBILITY OF SUCH DAMAGES. 1622131554Stjr@end enumerate 1623131554Stjr 1624131554Stjr@iftex 1625131554Stjr@heading END OF TERMS AND CONDITIONS 1626131554Stjr@end iftex 1627131554Stjr@ifinfo 1628131554Stjr@center END OF TERMS AND CONDITIONS 1629131554Stjr@end ifinfo 1630131554Stjr 163153564Sobrien@page 1632131554Stjr@unnumberedsec How to Apply These Terms to Your New Programs 1633131554Stjr 1634131554Stjr If you develop a new program, and you want it to be of the greatest 1635131554Stjrpossible use to the public, the best way to achieve this is to make it 1636131554Stjrfree software which everyone can redistribute and change under these terms. 1637131554Stjr 1638131554Stjr To do so, attach the following notices to the program. It is safest 1639131554Stjrto attach them to the start of each source file to most effectively 1640131554Stjrconvey the exclusion of warranty; and each file should have at least 1641131554Stjrthe ``copyright'' line and a pointer to where the full notice is found. 1642131554Stjr 1643131554Stjr@smallexample 1644131554Stjr@var{one line to give the program's name and an idea of what it does.} 1645131554StjrCopyright (C) 19@var{yy} @var{name of author} 1646131554Stjr 1647131554StjrThis program is free software; you can redistribute it and/or 1648131554Stjrmodify it under the terms of the GNU General Public License 1649131554Stjras published by the Free Software Foundation; either version 2 1650131554Stjrof the License, or (at your option) any later version. 1651131554Stjr 1652131554StjrThis program is distributed in the hope that it will be useful, 1653131554Stjrbut WITHOUT ANY WARRANTY; without even the implied warranty of 1654131554StjrMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1655131554StjrGNU General Public License for more details. 1656131554Stjr 1657131554StjrYou should have received a copy of the GNU General Public License 1658131554Stjralong with this program; if not, write to the Free Software 1659131554StjrFoundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 1660131554Stjr@end smallexample 1661131554Stjr 1662131554StjrAlso add information on how to contact you by electronic and paper mail. 1663131554Stjr 1664131554StjrIf the program is interactive, make it output a short notice like this 1665131554Stjrwhen it starts in an interactive mode: 1666131554Stjr 1667131554Stjr@smallexample 1668131554StjrGnomovision version 69, Copyright (C) 19@var{yy} @var{name of author} 1669131554StjrGnomovision comes with ABSOLUTELY NO WARRANTY; for details 1670131554Stjrtype `show w'. This is free software, and you are welcome 1671131554Stjrto redistribute it under certain conditions; type `show c' 1672131554Stjrfor details. 1673131554Stjr@end smallexample 1674131554Stjr 1675131554StjrThe hypothetical commands @samp{show w} and @samp{show c} should show 1676131554Stjrthe appropriate parts of the General Public License. Of course, the 1677131554Stjrcommands you use may be called something other than @samp{show w} and 1678131554Stjr@samp{show c}; they could even be mouse-clicks or menu items---whatever 1679131554Stjrsuits your program. 1680131554Stjr 1681131554StjrYou should also get your employer (if you work as a programmer) or your 1682131554Stjrschool, if any, to sign a ``copyright disclaimer'' for the program, if 1683131554Stjrnecessary. Here is a sample; alter the names: 1684131554Stjr 1685131554Stjr@smallexample 1686131554Stjr@group 1687131554StjrYoyodyne, Inc., hereby disclaims all copyright 1688131554Stjrinterest in the program `Gnomovision' 1689131554Stjr(which makes passes at compilers) written 1690131554Stjrby James Hacker. 1691131554Stjr 1692131554Stjr@var{signature of Ty Coon}, 1 April 1989 1693131554StjrTy Coon, President of Vice 1694131554Stjr@end group 1695131554Stjr@end smallexample 1696131554Stjr 1697131554StjrThis General Public License does not permit incorporating your program into 1698131554Stjrproprietary programs. If your program is a subroutine library, you may 1699131554Stjrconsider it more useful to permit linking proprietary applications with the 1700131554Stjrlibrary. If this is what you want to do, use the GNU Library General 1701131554StjrPublic License instead of this License. 1702131554Stjr 1703131554Stjr@node GNU Free Documentation License, Concept Index, GNU General Public License, Copying 1704131554Stjr@section GNU Free Documentation License 1705131554Stjr@center Version 1.1, March 2000 1706131554Stjr@cindex FDL, GNU Free Documentation License 1707131554Stjr 1708131554Stjr@display 1709131554StjrCopyright (C) 2000 Free Software Foundation, Inc. 1710131554Stjr59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 1711131554Stjr 1712131554StjrEveryone is permitted to copy and distribute verbatim copies 1713131554Stjrof this license document, but changing it is not allowed. 1714131554Stjr@end display 1715131554Stjr@sp 1 1716131554Stjr@enumerate 0 1717131554Stjr@item 1718131554StjrPREAMBLE 1719131554Stjr 1720131554StjrThe purpose of this License is to make a manual, textbook, or other 1721131554Stjrwritten document ``free'' in the sense of freedom: to assure everyone 1722131554Stjrthe effective freedom to copy and redistribute it, with or without 1723131554Stjrmodifying it, either commercially or noncommercially. Secondarily, 1724131554Stjrthis License preserves for the author and publisher a way to get 1725131554Stjrcredit for their work, while not being considered responsible for 1726131554Stjrmodifications made by others. 1727131554Stjr 1728131554StjrThis License is a kind of ``copyleft'', which means that derivative 1729131554Stjrworks of the document must themselves be free in the same sense. It 1730131554Stjrcomplements the GNU General Public License, which is a copyleft 1731131554Stjrlicense designed for free software. 1732131554Stjr 1733131554StjrWe have designed this License in order to use it for manuals for free 1734131554Stjrsoftware, because free software needs free documentation: a free 1735131554Stjrprogram should come with manuals providing the same freedoms that the 1736131554Stjrsoftware does. But this License is not limited to software manuals; 1737131554Stjrit can be used for any textual work, regardless of subject matter or 1738131554Stjrwhether it is published as a printed book. We recommend this License 1739131554Stjrprincipally for works whose purpose is instruction or reference. 1740131554Stjr 1741131554Stjr@sp 1 1742131554Stjr@item 1743131554StjrAPPLICABILITY AND DEFINITIONS 1744131554Stjr 1745131554StjrThis License applies to any manual or other work that contains a 1746131554Stjrnotice placed by the copyright holder saying it can be distributed 1747131554Stjrunder the terms of this License. The ``Document'', below, refers to any 1748131554Stjrsuch manual or work. Any member of the public is a licensee, and is 1749131554Stjraddressed as ``you''. 1750131554Stjr 1751131554StjrA ``Modified Version'' of the Document means any work containing the 1752131554StjrDocument or a portion of it, either copied verbatim, or with 1753131554Stjrmodifications and/or translated into another language. 1754131554Stjr 1755131554StjrA ``Secondary Section'' is a named appendix or a front-matter section of 1756131554Stjrthe Document that deals exclusively with the relationship of the 1757131554Stjrpublishers or authors of the Document to the Document's overall subject 1758131554Stjr(or to related matters) and contains nothing that could fall directly 1759131554Stjrwithin that overall subject. (For example, if the Document is in part a 1760131554Stjrtextbook of mathematics, a Secondary Section may not explain any 1761131554Stjrmathematics.) The relationship could be a matter of historical 1762131554Stjrconnection with the subject or with related matters, or of legal, 1763131554Stjrcommercial, philosophical, ethical or political position regarding 1764131554Stjrthem. 1765131554Stjr 1766131554StjrThe ``Invariant Sections'' are certain Secondary Sections whose titles 1767131554Stjrare designated, as being those of Invariant Sections, in the notice 1768131554Stjrthat says that the Document is released under this License. 1769131554Stjr 1770131554StjrThe ``Cover Texts'' are certain short passages of text that are listed, 1771131554Stjras Front-Cover Texts or Back-Cover Texts, in the notice that says that 1772131554Stjrthe Document is released under this License. 1773131554Stjr 1774131554StjrA ``Transparent'' copy of the Document means a machine-readable copy, 1775131554Stjrrepresented in a format whose specification is available to the 1776131554Stjrgeneral public, whose contents can be viewed and edited directly and 1777131554Stjrstraightforwardly with generic text editors or (for images composed of 1778131554Stjrpixels) generic paint programs or (for drawings) some widely available 1779131554Stjrdrawing editor, and that is suitable for input to text formatters or 1780131554Stjrfor automatic translation to a variety of formats suitable for input 1781131554Stjrto text formatters. A copy made in an otherwise Transparent file 1782131554Stjrformat whose markup has been designed to thwart or discourage 1783131554Stjrsubsequent modification by readers is not Transparent. A copy that is 1784131554Stjrnot ``Transparent'' is called ``Opaque''. 1785131554Stjr 1786131554StjrExamples of suitable formats for Transparent copies include plain 1787131554StjrASCII without markup, Texinfo input format, LaTeX input format, SGML 1788131554Stjror XML using a publicly available DTD, and standard-conforming simple 1789131554StjrHTML designed for human modification. Opaque formats include 1790131554StjrPostScript, PDF, proprietary formats that can be read and edited only 1791131554Stjrby proprietary word processors, SGML or XML for which the DTD and/or 1792131554Stjrprocessing tools are not generally available, and the 1793131554Stjrmachine-generated HTML produced by some word processors for output 1794131554Stjrpurposes only. 1795131554Stjr 1796131554StjrThe ``Title Page'' means, for a printed book, the title page itself, 1797131554Stjrplus such following pages as are needed to hold, legibly, the material 1798131554Stjrthis License requires to appear in the title page. For works in 1799131554Stjrformats which do not have any title page as such, ``Title Page'' means 1800131554Stjrthe text near the most prominent appearance of the work's title, 1801131554Stjrpreceding the beginning of the body of the text. 1802131554Stjr@sp 1 1803131554Stjr@item 1804131554StjrVERBATIM COPYING 1805131554Stjr 1806131554StjrYou may copy and distribute the Document in any medium, either 1807131554Stjrcommercially or noncommercially, provided that this License, the 1808131554Stjrcopyright notices, and the license notice saying this License applies 1809131554Stjrto the Document are reproduced in all copies, and that you add no other 1810131554Stjrconditions whatsoever to those of this License. You may not use 1811131554Stjrtechnical measures to obstruct or control the reading or further 1812131554Stjrcopying of the copies you make or distribute. However, you may accept 1813131554Stjrcompensation in exchange for copies. If you distribute a large enough 1814131554Stjrnumber of copies you must also follow the conditions in section 3. 1815131554Stjr 1816131554StjrYou may also lend copies, under the same conditions stated above, and 1817131554Stjryou may publicly display copies. 1818131554Stjr@sp 1 1819131554Stjr@item 1820131554StjrCOPYING IN QUANTITY 1821131554Stjr 1822131554StjrIf you publish printed copies of the Document numbering more than 100, 1823131554Stjrand the Document's license notice requires Cover Texts, you must enclose 1824131554Stjrthe copies in covers that carry, clearly and legibly, all these Cover 1825131554StjrTexts: Front-Cover Texts on the front cover, and Back-Cover Texts on 1826131554Stjrthe back cover. Both covers must also clearly and legibly identify 1827131554Stjryou as the publisher of these copies. The front cover must present 1828131554Stjrthe full title with all words of the title equally prominent and 1829131554Stjrvisible. You may add other material on the covers in addition. 1830131554StjrCopying with changes limited to the covers, as long as they preserve 1831131554Stjrthe title of the Document and satisfy these conditions, can be treated 1832131554Stjras verbatim copying in other respects. 1833131554Stjr 1834131554StjrIf the required texts for either cover are too voluminous to fit 1835131554Stjrlegibly, you should put the first ones listed (as many as fit 1836131554Stjrreasonably) on the actual cover, and continue the rest onto adjacent 1837131554Stjrpages. 1838131554Stjr 1839131554StjrIf you publish or distribute Opaque copies of the Document numbering 1840131554Stjrmore than 100, you must either include a machine-readable Transparent 1841131554Stjrcopy along with each Opaque copy, or state in or with each Opaque copy 1842131554Stjra publicly-accessible computer-network location containing a complete 1843131554StjrTransparent copy of the Document, free of added material, which the 1844131554Stjrgeneral network-using public has access to download anonymously at no 1845131554Stjrcharge using public-standard network protocols. If you use the latter 1846131554Stjroption, you must take reasonably prudent steps, when you begin 1847131554Stjrdistribution of Opaque copies in quantity, to ensure that this 1848131554StjrTransparent copy will remain thus accessible at the stated location 1849131554Stjruntil at least one year after the last time you distribute an Opaque 1850131554Stjrcopy (directly or through your agents or retailers) of that edition to 1851131554Stjrthe public. 1852131554Stjr 1853131554StjrIt is requested, but not required, that you contact the authors of the 1854131554StjrDocument well before redistributing any large number of copies, to give 1855131554Stjrthem a chance to provide you with an updated version of the Document. 1856131554Stjr@sp 1 1857131554Stjr@item 1858131554StjrMODIFICATIONS 1859131554Stjr 1860131554StjrYou may copy and distribute a Modified Version of the Document under 1861131554Stjrthe conditions of sections 2 and 3 above, provided that you release 1862131554Stjrthe Modified Version under precisely this License, with the Modified 1863131554StjrVersion filling the role of the Document, thus licensing distribution 1864131554Stjrand modification of the Modified Version to whoever possesses a copy 1865131554Stjrof it. In addition, you must do these things in the Modified Version: 1866131554Stjr 1867131554StjrA. Use in the Title Page (and on the covers, if any) a title distinct 1868131554Stjr from that of the Document, and from those of previous versions 1869131554Stjr (which should, if there were any, be listed in the History section 1870131554Stjr of the Document). You may use the same title as a previous version 1871131554Stjr if the original publisher of that version gives permission.@* 1872131554StjrB. List on the Title Page, as authors, one or more persons or entities 1873131554Stjr responsible for authorship of the modifications in the Modified 1874131554Stjr Version, together with at least five of the principal authors of the 1875131554Stjr Document (all of its principal authors, if it has less than five).@* 1876131554StjrC. State on the Title page the name of the publisher of the 1877131554Stjr Modified Version, as the publisher.@* 1878131554StjrD. Preserve all the copyright notices of the Document.@* 1879131554StjrE. Add an appropriate copyright notice for your modifications 1880131554Stjr adjacent to the other copyright notices.@* 1881131554StjrF. Include, immediately after the copyright notices, a license notice 1882131554Stjr giving the public permission to use the Modified Version under the 1883131554Stjr terms of this License, in the form shown in the Addendum below.@* 1884131554StjrG. Preserve in that license notice the full lists of Invariant Sections 1885131554Stjr and required Cover Texts given in the Document's license notice.@* 1886131554StjrH. Include an unaltered copy of this License.@* 1887131554StjrI. Preserve the section entitled ``History'', and its title, and add to 1888131554Stjr it an item stating at least the title, year, new authors, and 1889131554Stjr publisher of the Modified Version as given on the Title Page. If 1890131554Stjr there is no section entitled ``History'' in the Document, create one 1891131554Stjr stating the title, year, authors, and publisher of the Document as 1892131554Stjr given on its Title Page, then add an item describing the Modified 1893131554Stjr Version as stated in the previous sentence.@* 1894131554StjrJ. Preserve the network location, if any, given in the Document for 1895131554Stjr public access to a Transparent copy of the Document, and likewise 1896131554Stjr the network locations given in the Document for previous versions 1897131554Stjr it was based on. These may be placed in the ``History'' section. 1898131554Stjr You may omit a network location for a work that was published at 1899131554Stjr least four years before the Document itself, or if the original 1900131554Stjr publisher of the version it refers to gives permission.@* 1901131554StjrK. In any section entitled ``Acknowledgements'' or ``Dedications'', 1902131554Stjr preserve the section's title, and preserve in the section all the 1903131554Stjr substance and tone of each of the contributor acknowledgements 1904131554Stjr and/or dedications given therein.@* 1905131554StjrL. Preserve all the Invariant Sections of the Document, 1906131554Stjr unaltered in their text and in their titles. Section numbers 1907131554Stjr or the equivalent are not considered part of the section titles.@* 1908131554StjrM. Delete any section entitled ``Endorsements''. Such a section 1909131554Stjr may not be included in the Modified Version.@* 1910131554StjrN. Do not retitle any existing section as ``Endorsements'' 1911131554Stjr or to conflict in title with any Invariant Section.@* 1912131554Stjr@sp 1 1913131554StjrIf the Modified Version includes new front-matter sections or 1914131554Stjrappendices that qualify as Secondary Sections and contain no material 1915131554Stjrcopied from the Document, you may at your option designate some or all 1916131554Stjrof these sections as invariant. To do this, add their titles to the 1917131554Stjrlist of Invariant Sections in the Modified Version's license notice. 1918131554StjrThese titles must be distinct from any other section titles. 1919131554Stjr 1920131554StjrYou may add a section entitled ``Endorsements'', provided it contains 1921131554Stjrnothing but endorsements of your Modified Version by various 1922131554Stjrparties--for example, statements of peer review or that the text has 1923131554Stjrbeen approved by an organization as the authoritative definition of a 1924131554Stjrstandard. 1925131554Stjr 1926131554StjrYou may add a passage of up to five words as a Front-Cover Text, and a 1927131554Stjrpassage of up to 25 words as a Back-Cover Text, to the end of the list 1928131554Stjrof Cover Texts in the Modified Version. Only one passage of 1929131554StjrFront-Cover Text and one of Back-Cover Text may be added by (or 1930131554Stjrthrough arrangements made by) any one entity. If the Document already 1931131554Stjrincludes a cover text for the same cover, previously added by you or 1932131554Stjrby arrangement made by the same entity you are acting on behalf of, 1933131554Stjryou may not add another; but you may replace the old one, on explicit 1934131554Stjrpermission from the previous publisher that added the old one. 1935131554Stjr 1936131554StjrThe author(s) and publisher(s) of the Document do not by this License 1937131554Stjrgive permission to use their names for publicity for or to assert or 1938131554Stjrimply endorsement of any Modified Version. 1939131554Stjr@sp 1 1940131554Stjr@item 1941131554StjrCOMBINING DOCUMENTS 1942131554Stjr 1943131554StjrYou may combine the Document with other documents released under this 1944131554StjrLicense, under the terms defined in section 4 above for modified 1945131554Stjrversions, provided that you include in the combination all of the 1946131554StjrInvariant Sections of all of the original documents, unmodified, and 1947131554Stjrlist them all as Invariant Sections of your combined work in its 1948131554Stjrlicense notice. 1949131554Stjr 1950131554StjrThe combined work need only contain one copy of this License, and 1951131554Stjrmultiple identical Invariant Sections may be replaced with a single 1952131554Stjrcopy. If there are multiple Invariant Sections with the same name but 1953131554Stjrdifferent contents, make the title of each such section unique by 1954131554Stjradding at the end of it, in parentheses, the name of the original 1955131554Stjrauthor or publisher of that section if known, or else a unique number. 1956131554StjrMake the same adjustment to the section titles in the list of 1957131554StjrInvariant Sections in the license notice of the combined work. 1958131554Stjr 1959131554StjrIn the combination, you must combine any sections entitled ``History'' 1960131554Stjrin the various original documents, forming one section entitled 1961131554Stjr``History''; likewise combine any sections entitled ``Acknowledgements'', 1962131554Stjrand any sections entitled ``Dedications''. You must delete all sections 1963131554Stjrentitled ``Endorsements.'' 1964131554Stjr@sp 1 1965131554Stjr@item 1966131554StjrCOLLECTIONS OF DOCUMENTS 1967131554Stjr 1968131554StjrYou may make a collection consisting of the Document and other documents 1969131554Stjrreleased under this License, and replace the individual copies of this 1970131554StjrLicense in the various documents with a single copy that is included in 1971131554Stjrthe collection, provided that you follow the rules of this License for 1972131554Stjrverbatim copying of each of the documents in all other respects. 1973131554Stjr 1974131554StjrYou may extract a single document from such a collection, and distribute 1975131554Stjrit individually under this License, provided you insert a copy of this 1976131554StjrLicense into the extracted document, and follow this License in all 1977131554Stjrother respects regarding verbatim copying of that document. 1978131554Stjr@sp 1 1979131554Stjr@item 1980131554StjrAGGREGATION WITH INDEPENDENT WORKS 1981131554Stjr 1982131554StjrA compilation of the Document or its derivatives with other separate 1983131554Stjrand independent documents or works, in or on a volume of a storage or 1984131554Stjrdistribution medium, does not as a whole count as a Modified Version 1985131554Stjrof the Document, provided no compilation copyright is claimed for the 1986131554Stjrcompilation. Such a compilation is called an ``aggregate'', and this 1987131554StjrLicense does not apply to the other self-contained works thus compiled 1988131554Stjrwith the Document, on account of their being thus compiled, if they 1989131554Stjrare not themselves derivative works of the Document. 1990131554Stjr 1991131554StjrIf the Cover Text requirement of section 3 is applicable to these 1992131554Stjrcopies of the Document, then if the Document is less than one quarter 1993131554Stjrof the entire aggregate, the Document's Cover Texts may be placed on 1994131554Stjrcovers that surround only the Document within the aggregate. 1995131554StjrOtherwise they must appear on covers around the whole aggregate. 1996131554Stjr@sp 1 1997131554Stjr@item 1998131554StjrTRANSLATION 1999131554Stjr 2000131554StjrTranslation is considered a kind of modification, so you may 2001131554Stjrdistribute translations of the Document under the terms of section 4. 2002131554StjrReplacing Invariant Sections with translations requires special 2003131554Stjrpermission from their copyright holders, but you may include 2004131554Stjrtranslations of some or all Invariant Sections in addition to the 2005131554Stjroriginal versions of these Invariant Sections. You may include a 2006131554Stjrtranslation of this License provided that you also include the 2007131554Stjroriginal English version of this License. In case of a disagreement 2008131554Stjrbetween the translation and the original English version of this 2009131554StjrLicense, the original English version will prevail. 2010131554Stjr@sp 1 2011131554Stjr@item 2012131554StjrTERMINATION 2013131554Stjr 2014131554StjrYou may not copy, modify, sublicense, or distribute the Document except 2015131554Stjras expressly provided for under this License. Any other attempt to 2016131554Stjrcopy, modify, sublicense or distribute the Document is void, and will 2017131554Stjrautomatically terminate your rights under this License. However, 2018131554Stjrparties who have received copies, or rights, from you under this 2019131554StjrLicense will not have their licenses terminated so long as such 2020131554Stjrparties remain in full compliance. 2021131554Stjr@sp 1 2022131554Stjr@item 2023131554StjrFUTURE REVISIONS OF THIS LICENSE 2024131554Stjr 2025131554StjrThe Free Software Foundation may publish new, revised versions 2026131554Stjrof the GNU Free Documentation License from time to time. Such new 2027131554Stjrversions will be similar in spirit to the present version, but may 2028131554Stjrdiffer in detail to address new problems or concerns. See 2029131554Stjrhttp://www.gnu.org/copyleft/. 2030131554Stjr 2031131554StjrEach version of the License is given a distinguishing version number. 2032131554StjrIf the Document specifies that a particular numbered version of this 2033131554StjrLicense ``or any later version'' applies to it, you have the option of 2034131554Stjrfollowing the terms and conditions either of that specified version or 2035131554Stjrof any later version that has been published (not as a draft) by the 2036131554StjrFree Software Foundation. If the Document does not specify a version 2037131554Stjrnumber of this License, you may choose any version ever published (not 2038131554Stjras a draft) by the Free Software Foundation. 2039131554Stjr 2040131554Stjr@end enumerate 2041131554Stjr 2042131554Stjr@unnumberedsec ADDENDUM: How to use this License for your documents 2043131554Stjr 2044131554StjrTo use this License in a document you have written, include a copy of 2045131554Stjrthe License in the document and put the following copyright and 2046131554Stjrlicense notices just after the title page: 2047131554Stjr 2048131554Stjr@smallexample 2049131554Stjr@group 2050131554Stjr 2051131554Stjr Copyright (C) @var{year} @var{your name}. 2052131554Stjr Permission is granted to copy, distribute and/or modify this document 2053131554Stjr under the terms of the GNU Free Documentation License, Version 1.1 2054131554Stjr or any later version published by the Free Software Foundation; 2055131554Stjr with the Invariant Sections being @var{list their titles}, with the 2056131554Stjr Front-Cover Texts being @var{list}, and with the Back-Cover Texts being @var{list}. 2057131554Stjr A copy of the license is included in the section entitled ``GNU 2058131554Stjr Free Documentation License''. 2059131554Stjr@end group 2060131554Stjr@end smallexample 2061131554StjrIf you have no Invariant Sections, write ``with no Invariant Sections'' 2062131554Stjrinstead of saying which ones are invariant. If you have no 2063131554StjrFront-Cover Texts, write ``no Front-Cover Texts'' instead of 2064131554Stjr``Front-Cover Texts being @var{list}''; likewise for Back-Cover Texts. 2065131554Stjr 2066131554StjrIf your document contains nontrivial examples of program code, we 2067131554Stjrrecommend releasing these examples in parallel under your choice of 2068131554Stjrfree software license, such as the GNU General Public License, 2069131554Stjrto permit their use in free software. 2070131554Stjr 2071131554Stjr@page 2072131554Stjr@node Concept Index, Index, GNU Free Documentation License, Top 207353564Sobrien@unnumbered Concept Index 207453564Sobrien 207553564SobrienThis is a general index of all issues discussed in this manual, with the 207655360Sobrienexception of the @command{grep} commands and command-line options. 207753564Sobrien 207853564Sobrien@printindex cp 207953564Sobrien 208053564Sobrien@page 2081131554Stjr@node Index,, Concept Index, Top 208253564Sobrien@unnumbered Index 208353564Sobrien 208455360SobrienThis is an alphabetical list of all @command{grep} commands, command-line 208555360Sobrienoptions, and environment variables. 208653564Sobrien 208753564Sobrien@printindex fn 208853564Sobrien 208953564Sobrien@contents 209053564Sobrien@bye 2091