Skip to content

Instantly share code, notes, and snippets.

@rponte
Last active October 24, 2018 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save rponte/fc78d4dc571005f662606147115eb28a to your computer and use it in GitHub Desktop.
Save rponte/fc78d4dc571005f662606147115eb28a 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
@rponte
Copy link
Author

rponte commented Jul 13, 2018

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