Reputation: 51
I am looking for a way to determine the installed path of a Homebrew formula that includes the version number.
Currently I am aware of the following command,
brew --cellar pig
which will return,
/usr/local/Cellar/pig
However, the actual install path is,
/usr/local/Cellar/pig/0.15.0
which changes when newer/older versions are installed.
Is there any way to obtain this information using a brew command or the command line?
Upvotes: 1
Views: 1160
Reputation: 996
I find that the brew list $1
command in @melMass's function runs too slowly to be used repeatedly in my ~/.bash_profile
, so here's a version that should be faster, but assumes that all package paths are under their version subdir in $(brew --cellar $1)
:
brew_path() {
local p _p
while read _p; do
p=$_p
done < <(
pwd "$(brew --cellar $1)"/*
)
echo $p
}
Example:
$ brew_path pcre
/usr/local/Cellar/pcre/8.45
Upvotes: 0
Reputation: 195
You could use brew list <package>
and cut up to the version.
Eg:
$ brew list hbase | head -1 | sed 's/\(^.*\/hbase\/[^\/]*\).*/\1/'
/usr/local/Cellar/hbase/1.1.5
Update: See this more up to date solution.
Upvotes: 1
Reputation: 5159
Based on Christopher Gentle tips I have made the following function:
brew_path (){
brew list $1 | head -1 | sed "s/\(^.*\/$1\/[^\/]*\).*/\1/"
}
Example:
brew_path opencolorio
/usr/local/Cellar/opencolorio/1.1.0
Upvotes: 2