Wouldn't sth like
grep -r --include="$1" -n -i "$2"
do the same thing?
@Wolf480pl Loses highlighting, and less is just less useful unless you're 100% committed to terminal-only use. And still keeps the paths up front.
--color=always |less -RS
but yeah yours is better
Welcome to your niu world ! We are a cute and loving international community Ｏ(≧▽≦)Ｏ !