Skip to content

Instantly share code, notes, and snippets.

@jrelo
Forked from Remiii/finding.md
Created March 10, 2018 21:17
Show Gist options
  • Save jrelo/d6d449664174bf982520d9015bd17ad9 to your computer and use it in GitHub Desktop.
Save jrelo/d6d449664174bf982520d9015bd17ad9 to your computer and use it in GitHub Desktop.
Finding... Finding all files containing a text string in linux...

Finding

$ grep -rnw 'directory' -e "pattern"

-r is recursive, -n is line number and -w stands match the whole word. Along with these, --exclude or --include parameter could be used for efficient searching. Something like below:

$ grep --include={*.c,*.h} -rnw 'directory' -e "pattern"

This will only search through the files which have .c or .h extensions. Similarly a sample use of --exclude:

$ grep --exclude=*.o -rnw 'directory' -e "pattern"

Above will exclude searching all the files ending with .o extension.

Some options

  • i stands for upper/lower case (optional in your case)
  • ...

Mark: (Source)[http://stackoverflow.com/questions/16956810/finding-all-files-containing-a-text-string-in-linux]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment