Skip to content

Instantly share code, notes, and snippets.

@danielmwai
Forked from rponte/find-text-recursively.sh
Created October 24, 2018 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielmwai/5782f0dcc5eae798f2f993923a793d61 to your computer and use it in GitHub Desktop.
Save danielmwai/5782f0dcc5eae798f2f993923a793d61 to your computer and use it in GitHub Desktop.
Finding files with specific text recursively using grep - unix
#!/bin/bash
# without regex pattern
grep --recursive --include=\*.java -nHIi "utf-8" /my/dir
grep --recursive --include=\*.{java,xml} -nHIi "utf-8" /my/dir
# with regex pattern
grep --recursive --include=\*.{xml,java,jspx} -nHIiE "(utf-8|iso8859-1|windows-1252)" /my/dir
##
## keep the a comma (,) when searching through a single file extension. ie: {,xml}
grep --recursive --include=\*.{,java} -nHIi "utf-8" /my/dir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment