Monthly Archives: January 2015

Using grep to Find Files Containing Text

This command is used to find files in a directory structure containing a target search string. The command line utility ‘grep’ can be found on most modern Unix based systems.

$ grep --exclude=*\.{run,zip,tgz} -nr ./ -e "Hello World"
  • –exclude: multiple file types to ignore.
  • -nr: include line numbers in output display, recurse.
  • ./: search current directory.
  • -e: regular expression to search for follows.
  • “Hello World”: target search string.

Nothing ground-breaking here, this is more for my own documentation; I end up using this just not often enough to memorize it, but often enough I have to Google around a few minutes each time.