I have the following function defined in .bash_aliases
findphp () {
find -name '*.php' -exec grep -H --color "$@" "{}" \;
}
It allows me to run something like findphp 'function x' to find all references to function x in php files
Now I want to pass the file type to search, example js, css, ctp as a parameter in bash
I defined the follwing function and sourced .bash_aliases
myfind () {
find -name '*.$1' -exec grep -H --color "$2" "{}" \;
}
But it's not working, I tried single quotes, double quotes around the positional parameters with no avail.
How could I define a function that takes the file extension and search string as arguments from the command line?