David Lam David Lam - 2 years ago 84
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 Source

Sure. In bash:

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

And then call it like this:

findrecursive "hello"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download