I am trying to alias find and grep to a line as show below
alias f='find . -name $1 -type f -exec grep -i $2 '{}' \;'
I intend to run it as
f *.php function
but when I add this to .bash_profile and run it I am hit with
[a@a ~]$ f ss s
find: paths must precede expression
Usage: find [-H] [-L] [-P] [path...] [expression]
How do I resolve this?
Aliases don’t accept positional parameters. You’ll need to use a function.
You’ll also need to quote some of your arguments.
This defers the expansion of the glob so that
findperforms it rather than the shell.