Last active
January 14, 2017 17:59
-
-
Save fernviridian/b3aa591a755e5459c454 to your computer and use it in GitHub Desktop.
find string in files from current directory without git grep
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # simple script to find content of files based on extensions | |
| # and a given string | |
| # usage ./find.sh "some string to find in files" .py | |
| # will find all instances where that string was in a file.py | |
| phrase=$1 | |
| fileextension=$2 | |
| for file in `find $(pwd) -name \*$fileextension -print`; do | |
| if [ -e $file ]; then | |
| cat $file | grep -i "$phrase"; | |
| if [ $? -eq 0 ]; then | |
| echo $file; | |
| fi; | |
| fi; | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment