Grep

From wikinotes
Revision as of 00:27, 19 July 2021 by Will (talk | contribs) (→‎Usage)

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` \

multiline grep

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