Created
November 10, 2011 09:42
-
-
Save aprell/1354509 to your computer and use it in GitHub Desktop.
Searches for a string in all files of a directory. Useful wrapper for grep.
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 | |
usage="Usage: findstring <string> [directory]" | |
if [ $# -lt 1 ] || [ $# -gt 2 ]; then | |
echo $usage | |
exit 0 | |
fi | |
if [ $# -eq 1 ]; then | |
dir=`pwd` | |
else | |
dir=$2 | |
fi | |
echo "Searching for \"$1\" in $dir" | |
grep --recursive --color=auto --with-filename --line-number \ | |
--binary-files=without-match "$1" $dir |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment