Search code examples
bashshellgrepzshbsd

How do I alias BSD grep to search the current directory recursively with the input?


I have the same problem as the author here: How do I write an alias for grep -R?

I would like gr whatever to execute grep -nrI whatever ..

Do I require a function or can I do this with an alias?


Solution

  • I can't think of an elegant way to do this with an alias, but it's pretty easy if you define gr as a function:

    $ gr() { grep -nrI $1 .; }