CVSROOT:        /webcvs/grep
Module name:    grep
Changes by:     Jim Meyering <meyering> 25/04/11 13:06:09

Index: html_node/File-and-Directory-Selection.html
===================================================================
RCS file: /webcvs/grep/grep/manual/html_node/File-and-Directory-Selection.html,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- html_node/File-and-Directory-Selection.html 13 May 2023 09:23:52 -0000      
1.35
+++ html_node/File-and-Directory-Selection.html 11 Apr 2025 17:06:07 -0000      
1.36
@@ -1,11 +1,11 @@
 <!DOCTYPE html>
 <html>
-<!-- Created by GNU Texinfo 7.0dev, https://www.gnu.org/software/texinfo/ -->
+<!-- Created by GNU Texinfo 7.1.1, 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 © 1999-2002, 2005, 2008-2023 Free Software Foundation,
+Copyright © 1999-2002, 2005, 2008-2025 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>File and Directory Selection (GNU Grep 3.11)</title>
+<title>File and Directory Selection (GNU Grep 3.12)</title>
 
-<meta name="description" content="File and Directory Selection (GNU Grep 
3.11)">
-<meta name="keywords" content="File and Directory Selection (GNU Grep 3.11)">
+<meta name="description" content="File and Directory Selection (GNU Grep 
3.12)">
+<meta name="keywords" content="File and Directory Selection (GNU Grep 3.12)">
 <meta name="resource-type" content="document">
 <meta name="distribution" content="global">
 <meta name="Generator" content="makeinfo">
@@ -50,20 +50,18 @@
 <h4 class="subsection" id="File-and-Directory-Selection-1"><span>2.1.6 File 
and Directory Selection<a class="copiable-link" 
href="#File-and-Directory-Selection-1"> &para;</a></span></h4>
 
 <dl class="table">
-<dt><samp class="option">-a</samp></dt>
-<dt><samp class="option">--text</samp></dt>
-<dd><a class="index-entry-id" id="index-_002da"></a>
-<a class="index-entry-id" id="index-_002d_002dtext"></a>
+<dt><a class="index-entry-id" id="index-_002d_002dtext"></a>
 <a class="index-entry-id" id="index-suppress-binary-data"></a>
 <a class="index-entry-id" id="index-binary-files"></a>
-<p>Process a binary file as if it were text;
+<a id="index-_002da"></a><span><samp class="option">-a</samp><a 
class="copiable-link" href="#index-_002da"> &para;</a></span></dt>
+<dt><samp class="option">--text</samp></dt>
+<dd><p>Process a binary file as if it were text;
 this is equivalent to the &lsquo;<samp 
class="samp">--binary-files=text</samp>&rsquo; option.
 </p>
 </dd>
-<dt><samp class="option">--binary-files=<var class="var">type</var></samp></dt>
-<dd><a class="index-entry-id" id="index-_002d_002dbinary_002dfiles"></a>
-<a class="index-entry-id" id="index-binary-files-1"></a>
-<p>If a file&rsquo;s data or metadata
+<dt><a class="index-entry-id" id="index-binary-files-1"></a>
+<a id="index-_002d_002dbinary_002dfiles"></a><span><samp 
class="option">--binary-files=<var class="var">type</var></samp><a 
class="copiable-link" href="#index-_002d_002dbinary_002dfiles"> 
&para;</a></span></dt>
+<dd><p>If a file&rsquo;s data or metadata
 indicate that the file contains binary data,
 assume that the file is of type <var class="var">type</var>.
 Non-text bytes indicate binary data; these are either output bytes that are
@@ -77,9 +75,11 @@
 with a message to standard error saying that a binary file matches.
 </p>
 <p>If <var class="var">type</var> is &lsquo;<samp 
class="samp">without-match</samp>&rsquo;,
-when <code class="command">grep</code> discovers null input binary data
-it assumes that the rest of the file does not match;
+when <code class="command">grep</code> discovers null binary data in an input 
file
+it assumes that any unprocessed input does not match;
 this is equivalent to the <samp class="option">-I</samp> option.
+In this case the region of unprocessed input starts no later than the
+null binary data, and continues to end of file.
 </p>
 <p>If <var class="var">type</var> is &lsquo;<samp 
class="samp">text</samp>&rsquo;,
 <code class="command">grep</code> processes binary data as if it were text;
@@ -95,6 +95,16 @@
 <var class="var">type</var> is &lsquo;<samp class="samp">binary</samp>&rsquo; 
the pattern &lsquo;<samp class="samp">.</samp>&rsquo; (period) might not
 match a null byte.
 </p>
+<p>The heuristic that <code class="command">grep</code> uses to intuit whether 
input is
+binary is specific to <code class="command">grep</code> and may well be 
unsuitable for
+other applications, as it depends on command-line options, on locale,
+and on hardware and operating system characteristics such as system
+page size and input buffering.  For example, if the input consists of
+a matching text line followed by nonmatching data that contains a null
+byte, <code class="command">grep</code> might either output the matching line 
or treat
+the file as binary, depending on whether the unprocessed input happens
+to include the matching text line.
+</p>
 <p><em class="emph">Warning:</em> The <samp class="option">-a</samp> (<samp 
class="option">--binary-files=text</samp>) option
 might output binary garbage, which can have nasty side effects if the
 output is a terminal and if the terminal driver interprets some of it
@@ -104,12 +114,11 @@
 even if the matches are unsafe for direct display.
 </p>
 </dd>
-<dt><samp class="option">-D <var class="var">action</var></samp></dt>
-<dt><samp class="option">--devices=<var class="var">action</var></samp></dt>
-<dd><a class="index-entry-id" id="index-_002dD"></a>
-<a class="index-entry-id" id="index-_002d_002ddevices"></a>
+<dt><a class="index-entry-id" id="index-_002d_002ddevices"></a>
 <a class="index-entry-id" id="index-device-search"></a>
-<p>If an input file is a device, FIFO, or socket, use <var 
class="var">action</var> to process it.
+<a id="index-_002dD"></a><span><samp class="option">-D <var 
class="var">action</var></samp><a class="copiable-link" href="#index-_002dD"> 
&para;</a></span></dt>
+<dt><samp class="option">--devices=<var class="var">action</var></samp></dt>
+<dd><p>If an input file is a device, FIFO, or socket, use <var 
class="var">action</var> to process it.
 If <var class="var">action</var> is &lsquo;<samp 
class="samp">read</samp>&rsquo;,
 all devices are read just as if they were ordinary files.
 If <var class="var">action</var> is &lsquo;<samp 
class="samp">skip</samp>&rsquo;,
@@ -121,13 +130,12 @@
 This option has no effect on a file that is read via standard input.
 </p>
 </dd>
-<dt><samp class="option">-d <var class="var">action</var></samp></dt>
-<dt><samp class="option">--directories=<var 
class="var">action</var></samp></dt>
-<dd><a class="index-entry-id" id="index-_002dd"></a>
-<a class="index-entry-id" id="index-_002d_002ddirectories"></a>
+<dt><a class="index-entry-id" id="index-_002d_002ddirectories"></a>
 <a class="index-entry-id" id="index-directory-search"></a>
 <a class="index-entry-id" id="index-symbolic-links"></a>
-<p>If an input file is a directory, use <var class="var">action</var> to 
process it.
+<a id="index-_002dd"></a><span><samp class="option">-d <var 
class="var">action</var></samp><a class="copiable-link" href="#index-_002dd"> 
&para;</a></span></dt>
+<dt><samp class="option">--directories=<var 
class="var">action</var></samp></dt>
+<dd><p>If an input file is a directory, use <var class="var">action</var> to 
process it.
 By default, <var class="var">action</var> is &lsquo;<samp 
class="samp">read</samp>&rsquo;,
 which means that directories are read just as if they were ordinary files
 (some operating systems and file systems disallow this,
@@ -140,34 +148,31 @@
 this is equivalent to the <samp class="option">-r</samp> option.
 </p>
 </dd>
-<dt><samp class="option">--exclude=<var class="var">glob</var></samp></dt>
-<dd><a class="index-entry-id" id="index-_002d_002dexclude"></a>
-<a class="index-entry-id" id="index-exclude-files"></a>
+<dt><a class="index-entry-id" id="index-exclude-files"></a>
 <a class="index-entry-id" id="index-searching-directory-trees"></a>
-<p>Skip any command-line file with a name suffix that matches the pattern
+<a id="index-_002d_002dexclude"></a><span><samp class="option">--exclude=<var 
class="var">glob</var></samp><a class="copiable-link" 
href="#index-_002d_002dexclude"> &para;</a></span></dt>
+<dd><p>Skip any command-line file with a name suffix that matches the pattern
 <var class="var">glob</var>, using wildcard matching; a name suffix is either 
the whole
 name, or a trailing part that starts with a non-slash character
 immediately after a slash (&lsquo;<samp class="samp">/</samp>&rsquo;) in the 
name.
 When searching recursively, skip any subfile whose base
 name matches <var class="var">glob</var>; the base name is the part after the 
last
 slash.  A pattern can use
-&lsquo;<samp class="samp">*</samp>&rsquo;, &lsquo;<samp 
class="samp">?</samp>&rsquo;, and &lsquo;<samp 
class="samp">[</samp>&rsquo;...&lsquo;<samp class="samp">]</samp>&rsquo; as 
wildcards,
+&lsquo;<samp class="samp">*</samp>&rsquo;, &lsquo;<samp 
class="samp">?</samp>&rsquo;, and &lsquo;<samp 
class="samp">[</samp>&rsquo;&hellip;&lsquo;<samp class="samp">]</samp>&rsquo; 
as wildcards,
 and <code class="code">\</code> to quote a wildcard or backslash character 
literally.
 </p>
 </dd>
-<dt><samp class="option">--exclude-from=<var class="var">file</var></samp></dt>
-<dd><a class="index-entry-id" id="index-_002d_002dexclude_002dfrom"></a>
-<a class="index-entry-id" id="index-exclude-files-1"></a>
+<dt><a class="index-entry-id" id="index-exclude-files-1"></a>
 <a class="index-entry-id" id="index-searching-directory-trees-1"></a>
-<p>Skip files whose name matches any of the patterns
+<a id="index-_002d_002dexclude_002dfrom"></a><span><samp 
class="option">--exclude-from=<var class="var">file</var></samp><a 
class="copiable-link" href="#index-_002d_002dexclude_002dfrom"> 
&para;</a></span></dt>
+<dd><p>Skip files whose name matches any of the patterns
 read from <var class="var">file</var> (using wildcard matching as described
 under <samp class="option">--exclude</samp>).
 </p>
 </dd>
-<dt><samp class="option">--exclude-dir=<var class="var">glob</var></samp></dt>
-<dd><a class="index-entry-id" id="index-_002d_002dexclude_002ddir"></a>
-<a class="index-entry-id" id="index-exclude-directories"></a>
-<p>Skip any command-line directory with a name suffix that matches the
+<dt><a class="index-entry-id" id="index-exclude-directories"></a>
+<a id="index-_002d_002dexclude_002ddir"></a><span><samp 
class="option">--exclude-dir=<var class="var">glob</var></samp><a 
class="copiable-link" href="#index-_002d_002dexclude_002ddir"> 
&para;</a></span></dt>
+<dd><p>Skip any command-line directory with a name suffix that matches the
 pattern <var class="var">glob</var>.  When searching recursively, skip any 
subdirectory
 whose base name matches <var class="var">glob</var>.  Ignore any redundant 
trailing
 slashes in <var class="var">glob</var>.
@@ -178,11 +183,10 @@
 this is equivalent to the &lsquo;<samp 
class="samp">--binary-files=without-match</samp>&rsquo; option.
 </p>
 </dd>
-<dt><samp class="option">--include=<var class="var">glob</var></samp></dt>
-<dd><a class="index-entry-id" id="index-_002d_002dinclude"></a>
-<a class="index-entry-id" id="index-include-files"></a>
+<dt><a class="index-entry-id" id="index-include-files"></a>
 <a class="index-entry-id" id="index-searching-directory-trees-2"></a>
-<p>Search only files whose name matches <var class="var">glob</var>,
+<a id="index-_002d_002dinclude"></a><span><samp class="option">--include=<var 
class="var">glob</var></samp><a class="copiable-link" 
href="#index-_002d_002dinclude"> &para;</a></span></dt>
+<dd><p>Search only files whose name matches <var class="var">glob</var>,
 using wildcard matching as described under <samp 
class="option">--exclude</samp>.
 If contradictory <samp class="option">--include</samp> and <samp 
class="option">--exclude</samp> options are
 given, the last matching one wins.  If no <samp 
class="option">--include</samp> or
@@ -190,14 +194,13 @@
 such option is <samp class="option">--include</samp>.
 </p>
 </dd>
-<dt><samp class="option">-r</samp></dt>
-<dt><samp class="option">--recursive</samp></dt>
-<dd><a class="index-entry-id" id="index-_002dr"></a>
-<a class="index-entry-id" id="index-_002d_002drecursive"></a>
+<dt><a class="index-entry-id" id="index-_002d_002drecursive"></a>
 <a class="index-entry-id" id="index-recursive-search"></a>
 <a class="index-entry-id" id="index-searching-directory-trees-3"></a>
 <a class="index-entry-id" id="index-symbolic-links-1"></a>
-<p>For each directory operand,
+<a id="index-_002dr"></a><span><samp class="option">-r</samp><a 
class="copiable-link" href="#index-_002dr"> &para;</a></span></dt>
+<dt><samp class="option">--recursive</samp></dt>
+<dd><p>For each directory operand,
 read and process all files in that directory, recursively.
 Follow symbolic links on the command line, but skip symlinks
 that are encountered recursively.
@@ -205,14 +208,13 @@
 This is the same as the &lsquo;<samp 
class="samp">--directories=recurse</samp>&rsquo; option.
 </p>
 </dd>
-<dt><samp class="option">-R</samp></dt>
-<dt><samp class="option">--dereference-recursive</samp></dt>
-<dd><a class="index-entry-id" id="index-_002dR"></a>
-<a class="index-entry-id" id="index-_002d_002ddereference_002drecursive"></a>
+<dt><a class="index-entry-id" 
id="index-_002d_002ddereference_002drecursive"></a>
 <a class="index-entry-id" id="index-recursive-search-1"></a>
 <a class="index-entry-id" id="index-searching-directory-trees-4"></a>
 <a class="index-entry-id" id="index-symbolic-links-2"></a>
-<p>For each directory operand, read and process all files in that
+<a id="index-_002dR"></a><span><samp class="option">-R</samp><a 
class="copiable-link" href="#index-_002dR"> &para;</a></span></dt>
+<dt><samp class="option">--dereference-recursive</samp></dt>
+<dd><p>For each directory operand, read and process all files in that
 directory, recursively, following all symbolic links.
 </p>
 </dd>

Reply via email to