在别名中间有一个变量?

Having a variable in the middle of an alias?

我目前有一个常用的grep命令:

    grep -r -w <SEARCH> --include \*.c --include \*.cpp --include \*.h

想要将它作为别名(比如 grepc),但能够在中间更改 SEARCH。是否可以将它作为一个变量,如果可以,我将如何做/调用它?

无需为此用例传递参数

alias xyz="grep -r --include='*.'{c,h,cpp} -w"
xyz 'whatever'

当需要传递参数时,使用函数代替。参见 this Q&A on unix stackexchange for discussion between alias and functions