How can I identify the package/formula for a given file, or a listing of all of a package\'s owned files, in Homebrew?
This function works for commands stored in the $( brew --prefix )/bin
directory.
function brew_find_pkg {
cmds_to_search="$@"
brew_bin=$( brew --prefix )/bin
for cmd in $cmd_to_search ; do
if [ -L $brew_bin/$cmd ] ; then
\ls -l $brew_bin/$cmd |cut -f 2 -d '>'
else
echo "$cmd is not a brew command"
fi
done
}
E.g.:
$ brew_find_pkg gawk gcc alskdfja
../Cellar/gawk/4.1.4_1/bin/gawk
../Cellar/gcc/5.3.0/bin/gcc
alskdfja is not a brew command