Alias for recursive case insensitive search in current directory

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...' {} \;
1

2 Answers

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

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" .

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like