Search a string in files with grep, egrep, fgrep, pgrep, and locale — Cheat Sheet Linux

grep

grep <OPTIONS> <PATTERN> <FILENAME> displays the lines of a file corresponding to a specified pattern.

The arguments are:

  • -c (or --count): displays a count of matching lines for each input file,
  • -C <NUMBER> (or --context): displays context lines between continuous groups of matches,
  • -E <PATTERN> (or --extended-regexp): uses the pattern as an extended regular expression,

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store