Text Processing: Recursive search and replace: Difference between revisions

From WikiMLT
mNo edit summary
Line 2: Line 2:


<syntaxhighlight lang="shell" line="1">grep -rni 'string or regexp' *</syntaxhighlight>Where:
<syntaxhighlight lang="shell" line="1">grep -rni 'string or regexp' *</syntaxhighlight>Where:
* <code>*</code> - will match to all files and directories (which doesn't start with <code>.</code>, alternatively you may need to use <code>./</code> to match everything within the current directory;
* <code class="noTypo">*</code> - will match to all files and directories (which doesn't start with <code class="noTypo">.</code>, alternatively you may need to use <code class="noTypo">./</code> to match everything within the current directory;
* <code>-r</code>, <code>--recursive</code> - in this case works together with <code>*</code> (or <code>./</code>);
* <code class="noTypo">-r</code>, <code class="noTypo">--recursive</code> - in this case works together with <code class="noTypo">*</code> (or <code class="noTypo">./</code>);
* <code>-n</code> - output the line number where the match is found,
* <code class="noTypo">-n</code> - output the line number where the match is found,
* <code>-i</code>, <code>--ignore-case</code> - do case insensitive match.
* <code class="noTypo">-i</code>, <code class="noTypo">--ignore-case</code> - do case insensitive match.


<noinclude>
<noinclude>

Revision as of 11:23, 4 August 2022

grep -rni 'string or regexp' *

Where:

  • * – will match to all files and di­rec­to­ries (which doesn't start with ., al­ter­na­tive­ly you may need to use ./ to match every­thing with­in the cur­rent di­rec­to­ry;
  • -r, --recursive – in this case works to­geth­er with * (or ./);
  • -n – out­put the line num­ber where the match is found,
  • -i, --ignore-case – do case in­sen­si­tive match.