Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create grep alias with arguments

Lets say i have this search term:

grep -i -r --include=*.xib "img_28301.png" ./

how would i go about creating an alias that allows me to do this:

xibsearch img_28301.png 

and do the same thing?

like image 829
mskw Avatar asked Dec 18 '25 14:12

mskw


1 Answers

It will be much cleaner to have a function for this:

xibsearch() {
    grep -i -r --include=*.xib "$1" ./
}

As alias doesn't support positional parameters.

like image 73
anubhava Avatar answered Dec 21 '25 04:12

anubhava



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!