install – How to Check if Software is Installed with Homebrew

homebrewinstall

I'm installing a set of softwares/packages/formulas via homebrew with command like

brew install <formula1>
...
brew cask install <formula2>
...

I wonder if it's a good idea to verify if the softwares <formula1>, …, <formula2>, … are already installed and only trigger the above commands for the ones NOT already installed. If so, how?

Best Answer

you could do something like this:

brew list <formula1> || brew install <formula1>

This will error on list and continue with install if not installed otherwise it will just list package files. (one could modify this further as a function or alias in .bashrc to make it easier to type)