Lines Matching +full:- +full:b
35 <b>pcre2grep [options] [long options] [pattern] [path1 path2 ...]</b>
39 <b>pcre2grep</b> searches files for character patterns, in the same way as other
42 <a href="pcre2syntax.html"><b>pcre2syntax</b>(3)</a>
43 for a quick-reference summary of pattern syntax, or
44 <a href="pcre2pattern.html"><b>pcre2pattern</b>(3)</a>
62 pattern to be matched when neither <b>-e</b> nor <b>-f</b> is present.
64 arguments are treated as path names. At least one of <b>-e</b>, <b>-f</b>, or an
68 If no files are specified, <b>pcre2grep</b> reads the standard input. The
72 pcre2grep some-pattern file1 - file3
77 However, there are options that can change how <b>pcre2grep</b> behaves. In
78 particular, the <b>-M</b> option makes it possible to search for strings that
80 <b>-N</b> (<b>--newline</b>) option.
84 controlled by parameters that can be set by the <b>--buffer-size</b> and
85 <b>--max-buffer-size</b> options. The first of these sets the size of buffer
88 extending the buffer, up to the limit specified by <b>--max-buffer-size</b>. The
89 default values for these parameters can be set when <b>pcre2grep</b> is
101 BUFSIZ is defined in <b><stdio.h></b>. When there is more than one pattern
102 (specified by the use of <b>-e</b> and/or <b>-f</b>), each pattern is applied to
103 each line in the order in which they are defined, except that all the <b>-e</b>
104 patterns are tried before the <b>-f</b> patterns.
108 considered. However, if <b>--colour</b> (or <b>--color</b>) is used to colour the
109 matching substrings, or if <b>--only-matching</b>, <b>--file-offsets</b>, or
110 <b>--line-offsets</b> is used to output only the part of the line that matched
131 If the <b>LC_ALL</b> or <b>LC_CTYPE</b> environment variable is set,
132 <b>pcre2grep</b> uses the value to set a locale when calling the PCRE2 library.
133 The <b>--locale</b> option can be used to override this.
137 It is possible to compile <b>pcre2grep</b> so that it uses <b>libz</b> or
138 <b>libbz2</b> to read compressed files whose names end in <b>.gz</b> or
139 <b>.bz2</b>, respectively. You can find out whether your <b>pcre2grep</b> binary
141 <b>--help</b> option. If the appropriate support is not present, all files are
143 from a compressed .gz or .bz2 file, the <b>--line-buffered</b> option is
151 zero, the test for a binary file is not applied. See the <b>--binary-files</b>
158 from a file via the <b>-f</b> option may contain binary zeros.
163 example, both the <b>-H</b> and <b>-l</b> options affect the printing of file
170 <b>--</b>
176 <b>-A</b> <i>number</i>, <b>--after-context=</b><i>number</i>
181 context lines. A line containing "--" is output between each group of lines,
183 is expected to be relatively small. When <b>-c</b> is used, <b>-A</b> is ignored.
186 <b>-a</b>, <b>--text</b>
188 <b>--binary-files</b>=<i>text</i>.
191 <b>--allow-lookaround-bsk</b>
193 This option causes <b>pcre2grep</b> to set the PCRE2_EXTRA_ALLOW_LOOKAROUND_BSK
197 <b>-B</b> <i>number</i>, <b>--before-context=</b><i>number</i>
202 instead of a colon for the context lines. A line containing "--" is output
205 <b>-c</b> is used, <b>-B</b> is ignored.
208 <b>--binary-files=</b><i>word</i>
212 which is equivalent to the <b>-a</b> or <b>--text</b> option, binary files are
215 sent to a terminal. If the word is "without-match", which is equivalent to the
216 <b>-I</b> option, binary files are not processed at all; they are assumed not to
221 <b>--buffer-size=</b><i>number</i>
224 <b>--max-buffer-size</b> below.
227 <b>-C</b> <i>number</i>, <b>--context=</b><i>number</i>
229 This is equivalent to setting both <b>-A</b> and <b>-B</b> to the same value.
232 <b>-c</b>, <b>--count</b>
235 <b>-v</b> is set, because they failed to match. By default, this count is
237 <b>-M</b> (multiline) option is used (without <b>-v</b>), there may be more
242 being scanned, a count is output for each of them and the <b>-t</b> option can
244 <b>--files-with-matches</b> option is also used, only those files whose counts
245 are greater than zero are listed. When <b>-c</b> is used, the <b>-A</b>,
246 <b>-B</b>, and <b>-C</b> options are ignored.
249 <b>--colour</b>, <b>--color</b>
250 If this option is given without any data, it is equivalent to "--colour=auto".
255 <b>--colour=</b><i>value</i>, <b>--color=</b><i>value</i>
261 because <b>pcre2grep</b> has to search for all possible matches in a line, not
268 <b>pcre2grep</b> looks for GREP_COLORS or GREP_COLOR (in that order). The value
271 followed by two semicolon-separated colours, terminated by the end of the
284 <b>-D</b> <i>action</i>, <b>--devices=</b><i>action</i>
290 <b>-d</b> <i>action</i>, <b>--directories=</b><i>action</i>
292 Valid values are "read" (the default in non-Windows environments, for
293 compatibility with GNU grep), "recurse" (equivalent to the <b>-r</b> option), or
297 end-of-file; in others it may provoke an error.
300 <b>--depth-limit</b>=<i>number</i>
301 See <b>--match-limit</b> below.
304 <b>-e</b> <i>pattern</i>, <b>--regex=</b><i>pattern</i>, <b>--regexp=</b><i>pattern</i>
307 single pattern that starts with a hyphen. When <b>-e</b> is used, no argument
313 If <b>-f</b> is used with <b>-e</b>, the command line patterns are matched first,
315 these options are specified. Note that multiple use of <b>-e</b> is not the same
318 separately, with X first, <b>pcre2grep</b> finds X if it is present, even if it
320 matters only if you are using <b>-o</b> or <b>--colo(u)r</b> to show the part(s)
324 <b>--exclude</b>=<i>pattern</i>
327 obtained from <b>--file-list</b>, or by scanning a directory. The pattern is a
329 file name, not the entire path. The <b>-F</b>, <b>-w</b>, and <b>-x</b> options do
331 to specify multiple patterns. If a file name matches both an <b>--include</b>
332 and an <b>--exclude</b> pattern, it is excluded. There is no short form for this
336 <b>--exclude-from=</b><i>filename</i>
337 Treat each non-empty line of the file as the data for an <b>--exclude</b>
339 system's default. The <b>--newline</b> option has no effect on this option. This
344 <b>--exclude-dir</b>=<i>pattern</i>
346 whatever the setting of the <b>--recursive</b> option. This applies to all
348 <b>--file-list</b>, or by scanning a parent directory. The pattern is a PCRE2
350 name, not the entire path. The <b>-F</b>, <b>-w</b>, and <b>-x</b> options do not
352 specify more than one pattern. If a directory matches both <b>--include-dir</b>
353 and <b>--exclude-dir</b>, it is excluded. There is no short form for this
357 <b>-F</b>, <b>--fixed-strings</b>
358 Interpret each data-matching pattern as a list of fixed strings, separated by
360 this purpose is controlled by the <b>--newline</b> option. The <b>-w</b> (match
361 as a word) and <b>-x</b> (match whole line) options can be used with <b>-F</b>.
363 strings are found in it (subject to <b>-w</b> or <b>-x</b>, if present). This
365 files; it does not apply to patterns specified by any of the <b>--include</b> or
366 <b>--exclude</b> options.
369 <b>-f</b> <i>filename</i>, <b>--file=</b><i>filename</i>
373 system's default interpretation of \n. The <b>--newline</b> option has no
379 description of <b>-e</b> above.
384 as "-" to refer to the standard input. When <b>-f</b> is used, patterns
385 specified on the command line using <b>-e</b> may also be present; they are
390 <b>--file-list</b>=<i>filename</i>
395 on the command line. The file name can be given as "-" to refer to the standard
396 input. If <b>--file</b> and <b>--file-list</b> are both specified as "-",
399 end-of-file indication. If this option is given more than once, all the
403 <b>--file-offsets</b>
406 mode, no context is shown. That is, the <b>-A</b>, <b>-B</b>, and <b>-C</b>
408 shown separately. This option is mutually exclusive with <b>--output</b>,
409 <b>--line-offsets</b>, and <b>--only-matching</b>.
412 <b>-H</b>, <b>--with-filename</b>
417 file name. When the <b>-M</b> option causes a pattern to match more than one
419 previous <b>-h</b>, <b>-l</b>, or <b>-L</b> options.
422 <b>-h</b>, <b>--no-filename</b>
427 overrides any previous <b>-H</b>, <b>-L</b>, or <b>-l</b> options.
430 <b>--heap-limit</b>=<i>number</i>
431 See <b>--match-limit</b> below.
434 <b>--help</b>
440 <b>-I</b>
442 <b>--binary-files</b>=<i>without-match</i>.
445 <b>-i</b>, <b>--ignore-case</b>
449 <b>--include</b>=<i>pattern</i>
450 If any <b>--include</b> patterns are specified, the only files that are
452 <b>--exclude</b> pattern. This option does not affect directories, but it
454 <b>--file-list</b>, or by scanning a directory. The pattern is a PCRE2 regular
456 the entire path. The <b>-F</b>, <b>-w</b>, and <b>-x</b> options do not apply to
458 matches both an <b>--include</b> and an <b>--exclude</b> pattern, it is excluded.
462 <b>--include-from=</b><i>filename</i>
463 Treat each non-empty line of the file as the data for an <b>--include</b>
465 default. The <b>--newline</b> option has no effect on this option. This option
469 <b>--include-dir</b>=<i>pattern</i>
470 If any <b>--include-dir</b> patterns are specified, the only directories that
472 an <b>--exclude-dir</b> pattern. This applies to all directories, whether listed
473 on the command line, obtained from <b>--file-list</b>, or by scanning a parent
475 the final component of the directory name, not the entire path. The <b>-F</b>,
476 <b>-w</b>, and <b>-x</b> options do not apply to this pattern. The option may be
477 given any number of times. If a directory matches both <b>--include-dir</b> and
478 <b>--exclude-dir</b>, it is excluded. There is no short form for this option.
481 <b>-L</b>, <b>--files-without-match</b>
484 output once, on a separate line. This option overrides any previous <b>-H</b>,
485 <b>-h</b>, or <b>-l</b> options.
488 <b>-l</b>, <b>--files-with-matches</b>
492 in a file. However, if the <b>-c</b> (count) option is also used, matching
495 <b>-c</b> is a way of suppressing the listing of files with no matches that
496 occurs with <b>-c</b> on its own. This option overrides any previous <b>-H</b>,
497 <b>-h</b>, or <b>-L</b> options.
500 <b>--label</b>=<i>name</i>
506 <b>--line-buffered</b>
507 When this option is given, non-compressed input is read and processed line by
509 large chunks, unless <b>pcre2grep</b> can determine that it is reading from a
510 terminal, which is currently possible only in Unix-like environments or
513 pipe and you do not want <b>pcre2grep</b> to buffer up large amounts of data.
514 However, its use will affect performance, and the <b>-M</b> (multiline) option
516 <b>--line-buffered</b> is ignored.
519 <b>--line-offsets</b>
522 number is terminated by a colon (as usual; see the <b>-n</b> option), and the
524 That is, the <b>-A</b>, <b>-B</b>, and <b>-C</b> options are ignored. If there is
526 mutually exclusive with <b>--output</b>, <b>--file-offsets</b>, and
527 <b>--only-matching</b>.
530 <b>--locale</b>=<i>locale-name</i>
532 the value in the <b>LC_ALL</b> or <b>LC_CTYPE</b> environment variables. If no
537 <b>-M</b>, <b>--multiline</b>
541 used with <b>-M</b> may usefully contain literal newline characters and internal
546 If <b>-v</b> is set, none of the lines in a multi-line match are output. Once a
556 pcre2grep -M 'regular\s+expression' <file>
560 well as possibly handling a two-character newline sequence.
564 that <b>pcre2grep</b> buffers the input file as it scans it. With a sufficiently
565 large processing buffer, this should not be a problem, but the <b>-M</b> option
566 does not work when input is read line by line (see <b>--line-buffered</b>.)
569 <b>-m</b> <i>number</i>, <b>--max-count</b>=<i>number</i>
570 Stop processing after finding <i>number</i> matching lines, or non-matching
571 lines if <b>-v</b> is also set. Any trailing context lines are output after the
575 If <b>-c</b> is also set, the count that is output is never greater than
576 <i>number</i>. This option has no effect if used with <b>-L</b>, <b>-l</b>, or
577 <b>-q</b>, or when just checking for a match in a binary file.
580 <b>--match-limit</b>=<i>number</i>
586 The <b>--match-limit</b> option provides a means of limiting computing resource
591 value set by <b>--match-limit</b> is reached, an error occurs.
594 The <b>--heap-limit</b> option specifies, as a number of kibibytes (units of
601 The <b>--depth-limit</b> option limits the depth of nested backtracking points,
606 set smaller than <b>--match-limit</b>.
614 <b>--max-buffer-size</b>=<i>number</i>
616 set by <b>--buffer-size</b>. The maximum buffer size is silently forced to be no
620 <b>-N</b> <i>newline-type</i>, <b>--newline</b>=<i>newline-type</i>
624 pcre2grep -N CRLF 'some pattern' <file>
628 types are the single-character sequences CR (carriage return) and LF
629 (linefeed), the two-character sequence CRLF, an "anycrlf" type, which
632 are the three just mentioned, plus VT (vertical tab, U+000B), FF (form feed,
637 When the PCRE2 library is built, a default line-ending sequence is specified.
639 otherwise specified by this option, <b>pcre2grep</b> uses the library's default.
642 This option makes it possible to use <b>pcre2grep</b> to scan files that have
645 option, <b>pcre2grep</b> may behave in strange ways. Note that this option does
646 not apply to files specified by the <b>-f</b>, <b>--exclude-from</b>, or
647 <b>--include-from</b> options, which are expected to use the operating system's
651 <b>-n</b>, <b>--line-number</b>
654 being output, it precedes the line number. When the <b>-M</b> option causes a
656 number. This option is forced if <b>--line-offsets</b> is used.
659 <b>--no-jit</b>
660 If the PCRE2 library is built with support for just-in-time compiling (which
661 speeds up matching), <b>pcre2grep</b> automatically makes use of this, unless it
667 <b>-O</b> <i>text</i>, <b>--output</b>=<i>text</i>
669 the text specified in this option, followed by an operating-system standard
670 newline. In this mode, no context is shown. That is, the <b>-A</b>, <b>-B</b>,
671 and <b>-C</b> options are ignored. The <b>--newline</b> option has no effect on
672 this option, which is mutually exclusive with <b>--only-matching</b>,
673 <b>--file-offsets</b>, and <b>--line-offsets</b>. However, like
674 <b>--only-matching</b>, if there is more than one match in a line, each of them
689 $a is replaced by bell; $b by backspace; $e by escape; $f by form feed; $n by
709 <b>-o</b>, <b>--only-matching</b>
711 line. In this mode, no context is shown. That is, the <b>-A</b>, <b>-B</b>, and
712 <b>-C</b> options are ignored. If there is more than one match in a line, each
713 of them is shown separately, on a separate line of output. If <b>-o</b> is
714 combined with <b>-v</b> (invert the sense of the match to find non-matching
718 otherwise empty line. This option is mutually exclusive with <b>--output</b>,
719 <b>--file-offsets</b> and <b>--line-offsets</b>.
722 <b>-o</b><i>number</i>, <b>--only-matching</b>=<i>number</i>
725 limit can be changed via the <b>--om-capture</b> option. A pattern may contain
727 limit can be accessed by <b>-o</b>. An error occurs if the number specified by
728 <b>-o</b> is greater than the limit.
731 -o0 is the same as <b>-o</b> without a number. Because these options can be
733 given in the same shell item, for example, -o3 or --only-matching=2. The
734 comments given for the non-argument case above also apply to this option. If
742 -o3 -o1 -o3 causes the substrings matched by capturing parentheses 3 and 1 and
747 <b>--om-capture</b>=<i>number</i>
748 Set the number of capturing parentheses that can be accessed by <b>-o</b>. The
752 <b>--om-separator</b>=<i>text</i>
753 Specify a separating string for multiple occurrences of <b>-o</b>. The default
757 <b>-q</b>, <b>--quiet</b>
762 <b>-r</b>, <b>--recursive</b>
764 taking note of any <b>--include</b> and <b>--exclude</b> settings. By default, a
766 immediate end-of-file. This option is a shorthand for setting the <b>-d</b>
770 <b>--recursion-limit</b>=<i>number</i>
771 This is an obsolete synonym for <b>--depth-limit</b>. See <b>--match-limit</b>
775 <b>-s</b>, <b>--no-messages</b>
776 Suppress error messages about non-existent or unreadable files. Such files are
781 <b>-t</b>, <b>--total-count</b>
783 <b>-t</b> suppresses all output except for a grand total number of matching
784 lines (or non-matching lines if <b>-v</b> is used) in all the files. If <b>-t</b>
785 is used with <b>-c</b>, a grand total is output except when the previous output
788 "TOTAL:". Otherwise, it appears as just another number. The <b>-t</b> option is
789 ignored when used with <b>-L</b> (list files without matches), because the grand
793 <b>-u</b>, <b>--utf</b>
794 Operate in UTF-8 mode. This option is available only if PCRE2 has been compiled
795 with UTF-8 support. All patterns (including those for any <b>--exclude</b> and
796 <b>--include</b> options) and all lines that are scanned must be valid strings
797 of UTF-8 characters. If an invalid UTF-8 string is encountered, an error
801 <b>-U</b>, <b>--utf-allow-invalid</b>
802 As <b>--utf</b>, but in addition subject lines may contain invalid UTF-8 code
804 themselves, however, must still be valid UTF-8 strings. This facility allows
805 valid UTF-8 strings to be sought within arbitrary byte sequences in executable
806 or other binary files. For more details about matching in non-valid UTF-8
808 <a href="pcre2unicode.html"><b>pcre2unicode</b>(3)</a>
812 <b>-V</b>, <b>--version</b>
813 Write the version numbers of <b>pcre2grep</b> and the PCRE2 library to the
818 <b>-v</b>, <b>--invert-match</b>
821 as <b>--only-matching</b> and <b>--output</b>, which specify parts of a match
825 <b>-w</b>, <b>--word-regex</b>, <b>--word-regexp</b>
828 having "\b(?:" at the start of each pattern, and ")\b" at the end. This
830 files; it does not apply to patterns specified by any of the <b>--include</b> or
831 <b>--exclude</b> options.
834 <b>-x</b>, <b>--line-regex</b>, <b>--line-regexp</b>
840 by any of the <b>--include</b> or <b>--exclude</b> options.
844 The environment variables <b>LC_ALL</b> and <b>LC_CTYPE</b> are examined, in that
846 by the <b>--locale</b> option. If no locale is set, the PCRE2 library's default
851 The <b>-N</b> (<b>--newline</b>) option allows <b>pcre2grep</b> to scan files with
854 specified by the <b>-f</b>, <b>--file-list</b>, <b>--exclude-from</b>, or
855 <b>--include-from</b> options.
866 The newline setting does not affect the way in which <b>pcre2grep</b> writes
876 Many of the short and long forms of <b>pcre2grep</b>'s options are the same
877 as in the GNU <b>grep</b> program. Any long option of the form
878 <b>--xxx-regexp</b> (GNU terminology) is also available as <b>--xxx-regex</b>
879 (PCRE2 terminology). However, the <b>--depth-limit</b>, <b>--file-list</b>,
880 <b>--file-offsets</b>, <b>--heap-limit</b>, <b>--include-dir</b>,
881 <b>--line-offsets</b>, <b>--locale</b>, <b>--match-limit</b>, <b>-M</b>,
882 <b>--multiline</b>, <b>-N</b>, <b>--newline</b>, <b>--om-separator</b>,
883 <b>--output</b>, <b>-u</b>, <b>--utf</b>, <b>-U</b>, and <b>--utf-allow-invalid</b>
884 options are specific to <b>pcre2grep</b>, as is the use of the
885 <b>--only-matching</b> option with a capturing parentheses number.
889 <b>pcre2grep</b>. For example, the <b>--include</b> option's argument is a glob
890 for GNU <b>grep</b>, but a regular expression for <b>pcre2grep</b>. If both the
891 <b>-c</b> and <b>-l</b> options are given, GNU grep lists only file names,
892 without counts, but <b>pcre2grep</b> gives the counts as well.
900 -f/some/file
901 -f /some/file
903 The exception is the <b>-o</b> option, which may appear with or without data.
905 item, for example -o3.
912 --file=/some/file
913 --file /some/file
921 The exceptions to the above are the <b>--colour</b> (or <b>--color</b>) and
922 <b>--only-matching</b> options, for which the data is optional. If one of these
924 character. Otherwise <b>pcre2grep</b> will assume that it has no data.
928 <b>pcre2grep</b> has, by default, support for calling external programs or
931 when <b>pcre2grep</b> is built. You can find out whether your binary has support
932 for callouts by running it with the <b>--help</b> option. If callout support is
933 completely disabled, all callouts in patterns are ignored by <b>pcre2grep</b>.
940 <a href="pcre2callout.html"><b>pcre2callout</b></a>
941 documentation for details). Numbered callouts are ignored by <b>pcre2grep</b>;
944 <br><b>
946 </b><br>
951 <b>pcre2grep</b> was built. The rest of the callout string is processed as a
952 zero-terminated string, which means it should not contain any internal binary
954 escape processing as text from the <b>--output</b> (<b>-O</b>) option (see
968 <br><b>
970 </b><br>
972 This facility can be independently disabled when <b>pcre2grep</b> is built. It
973 is supported for Windows, where a call to <b>_spawnvp()</b> is used, for VMS,
974 where <b>lib$spawn()</b> is used, and for any Unix-like environment where
975 <b>fork()</b> and <b>execv()</b> are available.
986 started by a dollar character. These are the same as for the <b>--output</b>
987 (<b>-O</b>) option documented above, except that $0 cannot insert the matched
992 echo -e "abcde\n12345" | pcre2grep \
994 (?C"/bin/echo|Arg1: [$1] [$2] [$3]|Arg2: $|${1}$| ($4)")()' -
1004 are zero-terminated strings. This means that binary zero characters in the
1008 If running the program fails for any reason (including the non-existence of the
1018 in these circumstances. If this happens, <b>pcre2grep</b> outputs an error
1020 there are more than 20 such errors, <b>pcre2grep</b> gives up.
1023 The <b>--match-limit</b> option of <b>pcre2grep</b> can be used to set the
1025 memory used during matching; see the discussion of <b>--heap-limit</b> and
1026 <b>--depth-limit</b> above.
1031 for syntax errors, overlong lines, non-existent or inaccessible files (even if
1033 <b>-s</b> option to suppress error messages about inaccessible files does not
1042 <b>pcre2pattern</b>(3), <b>pcre2syntax</b>(3), <b>pcre2callout</b>(3),
1043 <b>pcre2unicode</b>(3).
1058 Copyright © 1997-2021 University of Cambridge.