Skip to content

Instantly share code, notes, and snippets.

@fernviridian
Last active January 14, 2017 17:59
Show Gist options
  • Select an option

  • Save fernviridian/b3aa591a755e5459c454 to your computer and use it in GitHub Desktop.

Select an option

Save fernviridian/b3aa591a755e5459c454 to your computer and use it in GitHub Desktop.
find string in files from current directory without git grep
# 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