grep-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Changes to grep/manual/html_node/grep-Programs.html,v


From: Jim Meyering
Subject: Changes to grep/manual/html_node/grep-Programs.html,v
Date: Wed, 22 Mar 2023 22:55:26 -0400 (EDT)

CVSROOT:        /webcvs/grep
Module name:    grep
Changes by:     Jim Meyering <meyering> 23/03/22 22:55:22

Index: html_node/grep-Programs.html
===================================================================
RCS file: /webcvs/grep/grep/manual/html_node/grep-Programs.html,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -b -r1.33 -r1.34
--- html_node/grep-Programs.html        3 Sep 2022 19:33:14 -0000       1.33
+++ html_node/grep-Programs.html        23 Mar 2023 02:55:21 -0000      1.34
@@ -1,11 +1,11 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd";>
+<!DOCTYPE html>
 <html>
-<!-- Created by GNU Texinfo 6.8, https://www.gnu.org/software/texinfo/ -->
+<!-- Created by GNU Texinfo 7.0dev, https://www.gnu.org/software/texinfo/ -->
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 <!-- This manual is for grep, a pattern matching engine.
 
-Copyright (C) 1999-2002, 2005, 2008-2022 Free Software Foundation,
+Copyright © 1999-2002, 2005, 2008-2023 Free Software Foundation,
 Inc.
 
 Permission is granted to copy, distribute and/or modify this document
@@ -14,10 +14,10 @@
 Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
 Texts.  A copy of the license is included in the section entitled
 "GNU Free Documentation License". -->
-<title>grep Programs (GNU Grep 3.8)</title>
+<title>grep Programs (GNU Grep 3.10)</title>
 
-<meta name="description" content="grep Programs (GNU Grep 3.8)">
-<meta name="keywords" content="grep Programs (GNU Grep 3.8)">
+<meta name="description" content="grep Programs (GNU Grep 3.10)">
+<meta name="keywords" content="grep Programs (GNU Grep 3.10)">
 <meta name="resource-type" content="document">
 <meta name="distribution" content="global">
 <meta name="Generator" content="makeinfo">
@@ -30,21 +30,10 @@
 <link href="Exit-Status.html" rel="prev" title="Exit Status">
 <style type="text/css">
 <!--
-a.copiable-anchor {visibility: hidden; text-decoration: none; line-height: 0em}
-a.summary-letter {text-decoration: none}
-blockquote.indentedblock {margin-right: 0em}
-div.display {margin-left: 3.2em}
+a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
 div.example {margin-left: 3.2em}
-kbd {font-style: oblique}
-pre.display {font-family: inherit}
-pre.format {font-family: inherit}
-pre.menu-comment {font-family: serif}
-pre.menu-preformatted {font-family: serif}
-span.nolinebreak {white-space: nowrap}
-span.roman {font-family: initial; font-weight: normal}
-span.sansserif {font-family: sans-serif; font-weight: normal}
-span:hover a.copiable-anchor {visibility: visible}
-ul.no-bullet {list-style: none}
+span:hover a.copiable-link {visibility: visible}
+ul.mark-bullet {list-style-type: disc}
 -->
 </style>
 <link rel="stylesheet" type="text/css" 
href="https://www.gnu.org/software/gnulib/manual.css";>
@@ -53,66 +42,107 @@
 </head>
 
 <body lang="en">
-<div class="section" id="grep-Programs">
-<div class="header">
+<div class="section-level-extent" id="grep-Programs">
+<div class="nav-panel">
 <p>
-Previous: <a href="Exit-Status.html" accesskey="p" rel="prev">Exit Status</a>, 
Up: <a href="Invoking.html" accesskey="u" rel="up">Invoking 
<code>grep</code></a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of 
contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" 
rel="index">Index</a>]</p>
+Previous: <a href="Exit-Status.html" accesskey="p" rel="prev">Exit Status</a>, 
Up: <a href="Invoking.html" accesskey="u" rel="up">Invoking <code 
class="command">grep</code></a> &nbsp; [<a href="index.html#SEC_Contents" 
title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" 
title="Index" rel="index">Index</a>]</p>
 </div>
 <hr>
-<span id="grep-Programs-1"></span><h3 class="section">2.4 <code>grep</code> 
Programs</h3>
-<span id="index-grep-programs"></span>
-<span id="index-variants-of-grep"></span>
+<h3 class="section" id="grep-Programs-1"><span>2.4 <code 
class="command">grep</code> Programs<a class="copiable-link" 
href="#grep-Programs-1"> &para;</a></span></h3>
+<a class="index-entry-id" id="index-grep-programs"></a>
+<a class="index-entry-id" id="index-variants-of-grep"></a>
 
-<p><code>grep</code> searches the named input files
+<p><code class="command">grep</code> searches the named input files
 for lines containing a match to the given patterns.
-By default, <code>grep</code> prints the matching lines.
-A file named <samp>-</samp> stands for standard input.
-If no input is specified, <code>grep</code> searches the working
-directory <samp>.</samp> if given a command-line option specifying
-recursion; otherwise, <code>grep</code> searches standard input.
-There are four major variants of <code>grep</code>,
+By default, <code class="command">grep</code> prints the matching lines.
+A file named <samp class="file">-</samp> stands for standard input.
+If no input is specified, <code class="command">grep</code> searches the 
working
+directory <samp class="file">.</samp> if given a command-line option specifying
+recursion; otherwise, <code class="command">grep</code> searches standard 
input.
+There are four major variants of <code class="command">grep</code>,
 controlled by the following options.
 </p>
-<dl compact="compact">
-<dt id='index-_002dG'><span><samp>-G</samp><a href='#index-_002dG' 
class='copiable-anchor'> &para;</a></span></dt>
-<dt><span><samp>--basic-regexp</samp></span></dt>
-<dd><span id="index-_002d_002dbasic_002dregexp"></span>
-<span id="index-matching-basic-regular-expressions"></span>
+<dl class="table">
+<dt><samp class="option">-G</samp></dt>
+<dt><samp class="option">--basic-regexp</samp></dt>
+<dd><a class="index-entry-id" id="index-_002dG"></a>
+<a class="index-entry-id" id="index-_002d_002dbasic_002dregexp"></a>
+<a class="index-entry-id" id="index-matching-basic-regular-expressions"></a>
 <p>Interpret patterns as basic regular expressions (BREs).
 This is the default.
 </p>
 </dd>
-<dt id='index-_002dE'><span><samp>-E</samp><a href='#index-_002dE' 
class='copiable-anchor'> &para;</a></span></dt>
-<dt><span><samp>--extended-regexp</samp></span></dt>
-<dd><span id="index-_002d_002dextended_002dregexp"></span>
-<span id="index-matching-extended-regular-expressions"></span>
+<dt><samp class="option">-E</samp></dt>
+<dt><samp class="option">--extended-regexp</samp></dt>
+<dd><a class="index-entry-id" id="index-_002dE"></a>
+<a class="index-entry-id" id="index-_002d_002dextended_002dregexp"></a>
+<a class="index-entry-id" id="index-matching-extended-regular-expressions"></a>
 <p>Interpret patterns as extended regular expressions (EREs).
-(<samp>-E</samp> is specified by POSIX.)
+(<samp class="option">-E</samp> is specified by POSIX.)
 </p>
 </dd>
-<dt id='index-_002dF'><span><samp>-F</samp><a href='#index-_002dF' 
class='copiable-anchor'> &para;</a></span></dt>
-<dt><span><samp>--fixed-strings</samp></span></dt>
-<dd><span id="index-_002d_002dfixed_002dstrings"></span>
-<span id="index-matching-fixed-strings"></span>
+<dt><samp class="option">-F</samp></dt>
+<dt><samp class="option">--fixed-strings</samp></dt>
+<dd><a class="index-entry-id" id="index-_002dF"></a>
+<a class="index-entry-id" id="index-_002d_002dfixed_002dstrings"></a>
+<a class="index-entry-id" id="index-matching-fixed-strings"></a>
 <p>Interpret patterns as fixed strings, not regular expressions.
-(<samp>-F</samp> is specified by POSIX.)
+(<samp class="option">-F</samp> is specified by POSIX.)
 </p>
 </dd>
-<dt id='index-_002dP'><span><samp>-P</samp><a href='#index-_002dP' 
class='copiable-anchor'> &para;</a></span></dt>
-<dt><span><samp>--perl-regexp</samp></span></dt>
-<dd><span id="index-_002d_002dperl_002dregexp"></span>
-<span id="index-matching-Perl_002dcompatible-regular-expressions"></span>
+<dt><samp class="option">-P</samp></dt>
+<dt><samp class="option">--perl-regexp</samp></dt>
+<dd><a class="index-entry-id" id="index-_002dP"></a>
+<a class="index-entry-id" id="index-_002d_002dperl_002dregexp"></a>
+<a class="index-entry-id" 
id="index-matching-Perl_002dcompatible-regular-expressions"></a>
 <p>Interpret patterns as Perl-compatible regular expressions (PCREs).
 PCRE support is here to stay, but consider this option experimental when
-combined with the <samp>-z</samp> (<samp>--null-data</samp>) option, and note 
that
-&lsquo;<samp>grep&nbsp;-P</samp>&rsquo; may warn of unimplemented features.
-See <a href="Other-Options.html">Other Options</a>.
+combined with the <samp class="option">-z</samp> (<samp 
class="option">--null-data</samp>) option, and note that
+&lsquo;<samp class="samp">grep&nbsp;-P</samp>&rsquo; may warn of unimplemented 
features.
+See <a class="xref" href="Other-Options.html">Other Options</a>.
 </p>
+<p>For documentation, refer to <a class="url" 
href="https://www.pcre.org/";>https://www.pcre.org/</a>, with these caveats:
+</p><ul class="itemize mark-bullet">
+<li>&lsquo;<samp class="samp">\d</samp>&rsquo; matches only the ten ASCII 
digits
+(and &lsquo;<samp class="samp">\D</samp>&rsquo; matches the complement), 
regardless of locale.
+Use &lsquo;<samp class="samp">\p{Nd}</samp>&rsquo; to also match non-ASCII 
digits.
+
+<p>When <code class="command">grep</code> is built with PCRE2 10.42 and 
earlier,
+&lsquo;<samp class="samp">\d</samp>&rsquo; and &lsquo;<samp 
class="samp">\D</samp>&rsquo; ignore in-regexp directives like &lsquo;<samp 
class="samp">(?aD)</samp>&rsquo;
+and work like &lsquo;<samp class="samp">[0-9]</samp>&rsquo; and &lsquo;<samp 
class="samp">[^0-9]</samp>&rsquo; respectively.
+However, later versions of PCRE2 likely will fix this,
+and the plan is for <code class="command">grep</code> to respect those 
directives if possible.
+</p>
+</li><li>Although PCRE tracks the syntax and semantics of Perl&rsquo;s regular
+expressions, the match is not always exact, partly because Perl
+evolves and a Perl installation may predate or postdate the PCRE2
+installation on the same host.
+
+</li><li>By default, <code class="command">grep</code> applies each regexp to 
a line at a time,
+so the &lsquo;<samp class="samp">(?s)</samp>&rsquo; directive (making 
&lsquo;<samp class="samp">.</samp>&rsquo; match line breaks)
+is generally ineffective.
+However, with <samp class="option">-z</samp> (<samp 
class="option">--null-data</samp>) it can work:
+<div class="example">
+<pre class="example-preformatted">$ printf 'a\nb\n' |grep -zP '(?s)a.b'
+a
+b
+</pre></div>
+<p>But beware: with the <samp class="option">-z</samp> (<samp 
class="option">--null-data</samp>) and a file
+containing no NUL byte, grep must read the entire file into memory
+before processing any of it.
+Thus, it will exhaust memory and fail for some large files.
+</p></li></ul>
+
 </dd>
 </dl>
 
 
 </div>
+<hr>
+<div class="nav-panel">
+<p>
+Previous: <a href="Exit-Status.html">Exit Status</a>, Up: <a 
href="Invoking.html">Invoking <code class="command">grep</code></a> &nbsp; [<a 
href="index.html#SEC_Contents" title="Table of contents" 
rel="contents">Contents</a>][<a href="Index.html" title="Index" 
rel="index">Index</a>]</p>
+</div>
 
 
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]