Fortunately, the Linux shell BASH provides an easy way to search for any string recursively in a directory. Just cd to the desired location and do -
grep -ri "[a phrase]" .
This would give you the results of a recursive (-r), case insensitive match (-i) for the supplied string in all the files in the current directory.
function grepcr() {
if [ $# -gt 0 ]; then
a=$1
shift
fi
sp=" "
while [ $# -gt 0 ]; do
a=$a$sp$1
shift
done
echo "grep -ri \"$a\" ."
grep -ri "$a" .
}
Just put this function in your ~/.bashrc file and then you can search for "a phrase" using the simple -
grepcr a phrase
As you may have guessed, "grepcr" stands for GREP Contents Recursively.
1 comment:
Useful, thanks !!
Post a Comment