This one works with no external dependencies (only shell builtins) and will work with busybox ash as well.
Sometimes you cant remember how to spell it exactly though, for those of us who just need to find a close match, there is this function to add to the bashrc:
find_bin(){
for x in ${PATH//://*${1}* }*${1}*; do
[ -f "$x" ] && echo $x
done
}
find_bin grep will list all of the binaries in $PATH with grep in the name along with their path {grep, egrep, fgrep, bugreport,... }
this can accept the following syntax:
- a*z - with az
- a?z - with a<1 character>z
- a[0-9]z - with az
- a[a-z]z - with az
- a[A-Z]z - with az
- a*{a,z}*z - with a .... same as a[az]z
if you occasionally want it to only match the whole word and not report egrep, fgrep or bugreport when you type grep, you can remove the asterisks and add them back at the command line only where you want them
find_bin(){
for x in ${PATH//://${1} }${1}; do
[ -f "$x" ] && echo $x
done
}
for this one extra syntax is needed for matching the beginnings and endings
- *grep - will match commands ending in gre (will find grep,egrep and fgrep, but not bugreport)
- grep - will only match exact string grep
- grep* - will match commands beginning with grep
- all patterns above apply as well