Grep: Difference between revisions

From wikinotes
Line 19: Line 19:
   -v  `# lines-not matching` \
   -v  `# lines-not matching` \
   -E  `# extended regex` \
   -E  `# extended regex` \
  -P  `# (gnu-only) perl extended regex (supports lookahead/behind)` \
</source>
</source>



Revision as of 00:29, 19 July 2021

Search file contents.

Documentation

man grep https://manpages.debian.org/buster/grep/grep.1.en.html

Usage

grep <dir> \
  -C3  `# show 3x lines before/after each match` \
  -l   `# show only matched files` \
  -i   `# case insensitive search` \
  -v   `# lines-not matching` \
  -E   `# extended regex` \
  -P   `# (gnu-only) perl extended regex (supports lookahead/behind)` \

multiline grep

grep -Pzo 'def[^\n]+\n\tfoo'