CVSROOT: /webcvs/grep Module name: grep Changes by: Jim Meyering <meyering> 23/03/22 22:55:22
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.33 retrieving revision 1.34 diff -u -b -r1.33 -r1.34 --- html_node/File-and-Directory-Selection.html 3 Sep 2022 19:33:14 -0000 1.33 +++ html_node/File-and-Directory-Selection.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>File and Directory Selection (GNU Grep 3.8)</title> +<title>File and Directory Selection (GNU Grep 3.10)</title> -<meta name="description" content="File and Directory Selection (GNU Grep 3.8)"> -<meta name="keywords" content="File and Directory Selection (GNU Grep 3.8)"> +<meta name="description" content="File and Directory Selection (GNU Grep 3.10)"> +<meta name="keywords" content="File and Directory Selection (GNU Grep 3.10)"> <meta name="resource-type" content="document"> <meta name="distribution" content="global"> <meta name="Generator" content="makeinfo"> @@ -31,21 +31,8 @@ <link href="Context-Line-Control.html" rel="prev" title="Context Line Control"> <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} -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} +a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em} +span:hover a.copiable-link {visibility: visible} --> </style> <link rel="stylesheet" type="text/css" href="https://www.gnu.org/software/gnulib/manual.css"> @@ -54,167 +41,177 @@ </head> <body lang="en"> -<div class="subsection" id="File-and-Directory-Selection"> -<div class="header"> +<div class="subsection-level-extent" id="File-and-Directory-Selection"> +<div class="nav-panel"> <p> Next: <a href="Other-Options.html" accesskey="n" rel="next">Other Options</a>, Previous: <a href="Context-Line-Control.html" accesskey="p" rel="prev">Context Line Control</a>, Up: <a href="Command_002dline-Options.html" accesskey="u" rel="up">Command-line Options</a> [<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="File-and-Directory-Selection-1"></span><h4 class="subsection">2.1.6 File and Directory Selection</h4> +<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"> ¶</a></span></h4> -<dl compact="compact"> -<dt id='index-_002da'><span><samp>-a</samp><a href='#index-_002da' class='copiable-anchor'> ¶</a></span></dt> -<dt><span><samp>--text</samp></span></dt> -<dd><span id="index-_002d_002dtext"></span> -<span id="index-suppress-binary-data"></span> -<span id="index-binary-files"></span> +<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> +<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; -this is equivalent to the ‘<samp>--binary-files=text</samp>’ option. +this is equivalent to the ‘<samp class="samp">--binary-files=text</samp>’ option. </p> </dd> -<dt id='index-_002d_002dbinary_002dfiles'><span><samp>--binary-files=<var>type</var></samp><a href='#index-_002d_002dbinary_002dfiles' class='copiable-anchor'> ¶</a></span></dt> -<dd><span id="index-binary-files-1"></span> +<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’s data or metadata indicate that the file contains binary data, -assume that the file is of type <var>type</var>. +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 -improperly encoded for the current locale (see <a href="Environment-Variables.html">Environment Variables</a>), or null input bytes when the -<samp>-z</samp> (<samp>--null-data</samp>) option is not given (see <a href="Other-Options.html">Other Options</a>). +improperly encoded for the current locale (see <a class="pxref" href="Environment-Variables.html">Environment Variables</a>), or null input bytes when the +<samp class="option">-z</samp> (<samp class="option">--null-data</samp>) option is not given (see <a class="pxref" href="Other-Options.html">Other Options</a>). </p> -<p>By default, <var>type</var> is ‘<samp>binary</samp>’, and <code>grep</code> +<p>By default, <var class="var">type</var> is ‘<samp class="samp">binary</samp>’, and <code class="command">grep</code> suppresses output after null input binary data is discovered, and suppresses output lines that contain improperly encoded data. -When some output is suppressed, <code>grep</code> follows any output +When some output is suppressed, <code class="command">grep</code> follows any output with a message to standard error saying that a binary file matches. </p> -<p>If <var>type</var> is ‘<samp>without-match</samp>’, -when <code>grep</code> discovers null input binary data +<p>If <var class="var">type</var> is ‘<samp class="samp">without-match</samp>’, +when <code class="command">grep</code> discovers null input binary data it assumes that the rest of the file does not match; -this is equivalent to the <samp>-I</samp> option. +this is equivalent to the <samp class="option">-I</samp> option. </p> -<p>If <var>type</var> is ‘<samp>text</samp>’, -<code>grep</code> processes binary data as if it were text; -this is equivalent to the <samp>-a</samp> option. -</p> -<p>When <var>type</var> is ‘<samp>binary</samp>’, <code>grep</code> may treat non-text -bytes as line terminators even without the <samp>-z</samp> -(<samp>--null-data</samp>) option. This means choosing ‘<samp>binary</samp>’ -versus ‘<samp>text</samp>’ can affect whether a pattern matches a file. For -example, when <var>type</var> is ‘<samp>binary</samp>’ the pattern ‘<samp>q$</samp>’ might -match ‘<samp>q</samp>’ immediately followed by a null byte, even though this -is not matched when <var>type</var> is ‘<samp>text</samp>’. Conversely, when -<var>type</var> is ‘<samp>binary</samp>’ the pattern ‘<samp>.</samp>’ (period) might not +<p>If <var class="var">type</var> is ‘<samp class="samp">text</samp>’, +<code class="command">grep</code> processes binary data as if it were text; +this is equivalent to the <samp class="option">-a</samp> option. +</p> +<p>When <var class="var">type</var> is ‘<samp class="samp">binary</samp>’, <code class="command">grep</code> may treat non-text +bytes as line terminators even without the <samp class="option">-z</samp> +(<samp class="option">--null-data</samp>) option. This means choosing ‘<samp class="samp">binary</samp>’ +versus ‘<samp class="samp">text</samp>’ can affect whether a pattern matches a file. For +example, when <var class="var">type</var> is ‘<samp class="samp">binary</samp>’ the pattern ‘<samp class="samp">q$</samp>’ might +match ‘<samp class="samp">q</samp>’ immediately followed by a null byte, even though this +is not matched when <var class="var">type</var> is ‘<samp class="samp">text</samp>’. Conversely, when +<var class="var">type</var> is ‘<samp class="samp">binary</samp>’ the pattern ‘<samp class="samp">.</samp>’ (period) might not match a null byte. </p> -<p><em>Warning:</em> The <samp>-a</samp> (<samp>--binary-files=text</samp>) option +<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 as commands. On the other hand, when reading files whose text -encodings are unknown, it can be helpful to use <samp>-a</samp> or to set -‘<samp>LC_ALL='C'</samp>’ in the environment, in order to find more matches +encodings are unknown, it can be helpful to use <samp class="option">-a</samp> or to set +‘<samp class="samp">LC_ALL='C'</samp>’ in the environment, in order to find more matches even if the matches are unsafe for direct display. </p> </dd> -<dt id='index-_002dD'><span><samp>-D <var>action</var></samp><a href='#index-_002dD' class='copiable-anchor'> ¶</a></span></dt> -<dt><span><samp>--devices=<var>action</var></samp></span></dt> -<dd><span id="index-_002d_002ddevices"></span> -<span id="index-device-search"></span> -<p>If an input file is a device, FIFO, or socket, use <var>action</var> to process it. -If <var>action</var> is ‘<samp>read</samp>’, +<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> +<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. +If <var class="var">action</var> is ‘<samp class="samp">read</samp>’, all devices are read just as if they were ordinary files. -If <var>action</var> is ‘<samp>skip</samp>’, +If <var class="var">action</var> is ‘<samp class="samp">skip</samp>’, devices, FIFOs, and sockets are silently skipped. By default, devices are read if they are on the command line or if the -<samp>-R</samp> (<samp>--dereference-recursive</samp>) option is used, and are -skipped if they are encountered recursively and the <samp>-r</samp> -(<samp>--recursive</samp>) option is used. +<samp class="option">-R</samp> (<samp class="option">--dereference-recursive</samp>) option is used, and are +skipped if they are encountered recursively and the <samp class="option">-r</samp> +(<samp class="option">--recursive</samp>) option is used. This option has no effect on a file that is read via standard input. </p> </dd> -<dt id='index-_002dd'><span><samp>-d <var>action</var></samp><a href='#index-_002dd' class='copiable-anchor'> ¶</a></span></dt> -<dt><span><samp>--directories=<var>action</var></samp></span></dt> -<dd><span id="index-_002d_002ddirectories"></span> -<span id="index-directory-search"></span> -<span id="index-symbolic-links"></span> -<p>If an input file is a directory, use <var>action</var> to process it. -By default, <var>action</var> is ‘<samp>read</samp>’, +<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> +<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. +By default, <var class="var">action</var> is ‘<samp class="samp">read</samp>’, which means that directories are read just as if they were ordinary files (some operating systems and file systems disallow this, -and will cause <code>grep</code> +and will cause <code class="command">grep</code> to print error messages for every directory or silently skip them). -If <var>action</var> is ‘<samp>skip</samp>’, directories are silently skipped. -If <var>action</var> is ‘<samp>recurse</samp>’, -<code>grep</code> reads all files under each directory, recursively, +If <var class="var">action</var> is ‘<samp class="samp">skip</samp>’, directories are silently skipped. +If <var class="var">action</var> is ‘<samp class="samp">recurse</samp>’, +<code class="command">grep</code> reads all files under each directory, recursively, following command-line symbolic links and skipping other symlinks; -this is equivalent to the <samp>-r</samp> option. +this is equivalent to the <samp class="option">-r</samp> option. </p> </dd> -<dt id='index-_002d_002dexclude'><span><samp>--exclude=<var>glob</var></samp><a href='#index-_002d_002dexclude' class='copiable-anchor'> ¶</a></span></dt> -<dd><span id="index-exclude-files"></span> -<span id="index-searching-directory-trees"></span> +<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> +<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 -<var>glob</var>, using wildcard matching; a name suffix is either the whole +<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 (‘<samp>/</samp>’) in the name. +immediately after a slash (‘<samp class="samp">/</samp>’) in the name. When searching recursively, skip any subfile whose base -name matches <var>glob</var>; the base name is the part after the last +name matches <var class="var">glob</var>; the base name is the part after the last slash. A pattern can use -‘<samp>*</samp>’, ‘<samp>?</samp>’, and ‘<samp>[</samp>’...‘<samp>]</samp>’ as wildcards, -and <code>\</code> to quote a wildcard or backslash character literally. +‘<samp class="samp">*</samp>’, ‘<samp class="samp">?</samp>’, and ‘<samp class="samp">[</samp>’...‘<samp class="samp">]</samp>’ as wildcards, +and <code class="code">\</code> to quote a wildcard or backslash character literally. </p> </dd> -<dt id='index-_002d_002dexclude_002dfrom'><span><samp>--exclude-from=<var>file</var></samp><a href='#index-_002d_002dexclude_002dfrom' class='copiable-anchor'> ¶</a></span></dt> -<dd><span id="index-exclude-files-1"></span> -<span id="index-searching-directory-trees-1"></span> +<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> +<a class="index-entry-id" id="index-searching-directory-trees-1"></a> <p>Skip files whose name matches any of the patterns -read from <var>file</var> (using wildcard matching as described -under <samp>--exclude</samp>). +read from <var class="var">file</var> (using wildcard matching as described +under <samp class="option">--exclude</samp>). </p> </dd> -<dt id='index-_002d_002dexclude_002ddir'><span><samp>--exclude-dir=<var>glob</var></samp><a href='#index-_002d_002dexclude_002ddir' class='copiable-anchor'> ¶</a></span></dt> -<dd><span id="index-exclude-directories"></span> +<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 -pattern <var>glob</var>. When searching recursively, skip any subdirectory -whose base name matches <var>glob</var>. Ignore any redundant trailing -slashes in <var>glob</var>. +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>. </p> </dd> -<dt><span><samp>-I</samp></span></dt> +<dt><samp class="option">-I</samp></dt> <dd><p>Process a binary file as if it did not contain matching data; -this is equivalent to the ‘<samp>--binary-files=without-match</samp>’ option. +this is equivalent to the ‘<samp class="samp">--binary-files=without-match</samp>’ option. </p> </dd> -<dt id='index-_002d_002dinclude'><span><samp>--include=<var>glob</var></samp><a href='#index-_002d_002dinclude' class='copiable-anchor'> ¶</a></span></dt> -<dd><span id="index-include-files"></span> -<span id="index-searching-directory-trees-2"></span> -<p>Search only files whose name matches <var>glob</var>, -using wildcard matching as described under <samp>--exclude</samp>. -If contradictory <samp>--include</samp> and <samp>--exclude</samp> options are -given, the last matching one wins. If no <samp>--include</samp> or -<samp>--exclude</samp> options match, a file is included unless the first -such option is <samp>--include</samp>. -</p> -</dd> -<dt id='index-_002dr'><span><samp>-r</samp><a href='#index-_002dr' class='copiable-anchor'> ¶</a></span></dt> -<dt><span><samp>--recursive</samp></span></dt> -<dd><span id="index-_002d_002drecursive"></span> -<span id="index-recursive-search"></span> -<span id="index-searching-directory-trees-3"></span> -<span id="index-symbolic-links-1"></span> +<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> +<a class="index-entry-id" id="index-searching-directory-trees-2"></a> +<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 +<samp class="option">--exclude</samp> options match, a file is included unless the first +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> +<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, read and process all files in that directory, recursively. Follow symbolic links on the command line, but skip symlinks that are encountered recursively. Note that if no file operand is given, grep searches the working directory. -This is the same as the ‘<samp>--directories=recurse</samp>’ option. +This is the same as the ‘<samp class="samp">--directories=recurse</samp>’ option. </p> </dd> -<dt id='index-_002dR'><span><samp>-R</samp><a href='#index-_002dR' class='copiable-anchor'> ¶</a></span></dt> -<dt><span><samp>--dereference-recursive</samp></span></dt> -<dd><span id="index-_002d_002ddereference_002drecursive"></span> -<span id="index-recursive-search-1"></span> -<span id="index-searching-directory-trees-4"></span> -<span id="index-symbolic-links-2"></span> +<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> +<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 directory, recursively, following all symbolic links. </p> @@ -223,7 +220,7 @@ </div> <hr> -<div class="header"> +<div class="nav-panel"> <p> Next: <a href="Other-Options.html">Other Options</a>, Previous: <a href="Context-Line-Control.html">Context Line Control</a>, Up: <a href="Command_002dline-Options.html">Command-line Options</a> [<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>
