Text Processing: Recursive search and replace: Difference between revisions
From WikiMLT
mNo edit summary |
mNo edit summary |
||
Line 1: | Line 1: | ||
<noinclude>{{ContentArticleHeader/Linux_Server}}</noinclude> | <noinclude>{{ContentArticleHeader/Linux_Server}}</noinclude> | ||
<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 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 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 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 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 class="noTypo">-n</code>, --line-number - output the line number where the match is found, | * <code class="noTypo">-n</code>, <code class="noTypo">--line-number</code> - output the line number where the match is found, | ||
* <code class="noTypo">-i</code>, <code class="noTypo">--ignore-case</code> - do case insensitive match. | * <code class="noTypo">-i</code>, <code class="noTypo">--ignore-case</code> - do case insensitive match. | ||
<noinclude> | <noinclude> | ||
<div id='devStage'> | <div id='devStage'> |
Revision as of 10:28, 4 August 2022
grep -rni 'string or regexp' *
Where:
*
– will match to all files and directories (which doesn't start with.
, alternatively you may need to use./
to match everything within the current directory;-r
,--recursive
– in this case works together with*
(or./
);-n
,--line-number
– output the line number where the match is found,-i
,--ignore-case
– do case insensitive match.