10

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?

21

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)

  • How can this be done in a Brewfile? – Jack Moody Jan 28 at 16:04
5

It should also be noted that you can type brew info <formula> which will tell you whether or not a formula is installed. You can parse the response for "Not installed" and then run the installer if it finds the string.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .