With Homebrew, how to check if a software/package is installed? I'm installing a set of softwares/packages/formulas via homebrew with command like

brew install &lt;formula1&gt;
...
brew cask install &lt;formula2&gt;
...


I wonder if it's a good idea to verify if the softwares &lt;formula1&gt;, ..., &lt;formula2&gt;, ... are already installed and only trigger the above commands for the ones NOT already installed. If so, how?
you could do something like this: 

brew list &lt;formula1&gt; || brew install &lt;formula1&gt;


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)