To check if a Homebrew package is installed, execute the following. The example below checks to see if fzf
is installed.
brew ls --versions fzf
To utilize within a script, use with an if
statement.
if [ -z "$(brew ls --versions fzf)" ]; then
echo 'the package fzf is not installed'
else
echo 'the package fzf is installed'
fi