Skip to content

listing all files containing specific text


  • /foo/bar/ represents a directory to recursively search within.
  • baz represents the text to search for.

Use grep -inr '/foo/bar/' -e 'baz'.


  • The -e option specifies a regular expression.
  • The -i option disables case sensitivity.
  • The -n option prefixes each outputted line with a line number.
  • The -r option enables recursion.

prior work


Some rights reserved: CC BY-SA 3.0. Includes significant content from a question on Stack Overflow by Nathan and an answer on Stack Overflow by rakib_ with changes made, including converting the original HTML to Markdown.