I prefer regular expressions with -regex over the shell pattern syntax of -name. I also want to use the posix-egrep type, so I'd like to do something likealias find=find -regextype posix-egrepbut that is an error since the path has to come before the expression. However, the -regextype has to be first in the expressions (or before using -regex or -iregex).I just want to alias or have a shell function find so that it works the same as usual, just ready to use posix-regex whenever I decide to use the -regex or -iregex option. How can I do this?
How to alias part of expression for find?
find;alias
since the find arguments are positional a function would be a better solution.find(){  command find $1 -regextype posix-egrep ${@:2}}since you want to overwrite the original command you need to use the full path of find so that your new function doesn't create an infinite loop of calling itself.by using a function instead of an alias we can use positional argument variables ($1-$n).  since you also might want to add other things to the end of your find we append the command with ${@:2} which appends all but the first argument (your path) using array slicing.