David Lam David Lam - 7 months ago 15
Bash Question

is there a shell / bash way to alias... find . -type f -exec grep -l <some word here> {} \;;

basically, this command does a recursive grep through all files in all sub-directories and I use it ALOT

but it's looooong and takes awhile to type

so I was wondering if instead of...

$ find . -type f -exec grep -l <some word here> {} \;;


that there was a way to alias it or something in my .bashrc so that I could just do something like...

$ findrecursive <some word here>

Answer

Sure. In bash:

function findrecursive() { find . -type f -exec grep -l "$1" {} \;; }

And then call it like this:

findrecursive "hello"