Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I set an alias, such as "mysearch", which will search for a string recursively in the directory I'm standing in. It should be as below:

mysearch "this table..." 


find -type f -exec grep -i -l 'this table...' {} \;
share|improve this question
Why do you need find at all? grep had a recursive (-r) option. – FatalError Mar 28 '12 at 17:38

Here's one: alias mysearch='find . -type f | xargs grep -i -l $1'

share|improve this answer

I'd say like this (for bash):

function mysearch { grep -ril "$1" .; }

The issue with an alias is that it only allows you to append to the command, not insert into the middle. As an alias, this might be more what you want:

alias rgrep="grep -ril"

Then you could use it like:

rgrep "search string" .
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.