Last active
March 25, 2019 15:36
-
-
Save junquera/4a887af3a65a6ba6a8c89f5b18e4d9f0 to your computer and use it in GitHub Desktop.
Find a text occurrence in all the files in a path
This file contains 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
#!/bin/bash | |
PATH_TO_FIND="$1" | |
TEXT_TO_FIND="$2" | |
find $1 -type f | | |
while read f; do | |
if [ $(grep $2 "$f" | wc -l) -gt 0 ]; then | |
echo $f | |
else | |
if [ $(echo "$f" | grep $2 | wc -l) -gt 0 ]; then | |
echo $f | |
fi; | |
fi; | |
done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment