You can install multiple homebrew formulas by brew install package1 package2
. But if you have a text file with all the packages that you would like to install. How would you do it?
brew install < packages.txt
doesn't work. It gives me the response: This command requires a formula argument
You can install multiple homebrew formulas by brew install package1 package2 . But if you have a text file with all the packages that you would like to install.
There should be no problem doing that. Homebrew will just download the files needed to brew the formula, then run the configuration and compilation by itself.
Like this:
brew install $(cat packages.txt)
or even just
brew install $(<packages.txt)
Here's an alternative one-line approach, which bypasses the need to create a file as an in-between step:
brew install $( brew search my-search-term | grep my-filter-term | tr '\n' ' ' )
vs.
brew search x | grep y > install_list.txt
brew install $( < install_list.txt )
Alternative (using awk):
brew search x | awk '/inclusion string/ && !/exclusion string/' | tr '\n' ' ' )
Suppose I wanted to install all the Nerd Fonts not currently on my machine in one go.
brew search fonts
will give multiple rows in results – similar to the default output from ls
:
brpro ➜ ~ brew search font
==> Partial Matches
birdfont font-hack-nerd-font
dfontsplitter font-hack-nerd-font-mono
font-3270 font-halant font-noto-sans-tibetan
font-3270-nerd-font ✔ font-hammersmith-one
font-3270-nerd-font-mono ✔ font-han-nom-a
font-abeezee font-hanalei font-noto-sans-vai
(...)
Piping the output to grep -i nerd
gives a single line-separated list of only the taps we want.
brpro ➜ ~ brew search font | grep -i nerd
font-3270-nerd-font
font-3270-nerd-font-mono
font-anonymouspro-nerd-font
font-anonymouspro-nerd-font-mono
font-arimo-nerd-font
font-arimo-nerd-font-mono
font-aurulentsansmono-nerd-font
(...)
We can use tr
to convert this output to a whitespace-separated single line:
brpro ➜ ~ brew search font | grep nerd | tr '\n' ' '
font-3270-nerd-font font-3270-nerd-font-mono font-anonymouspro-nerd-font font-anonymouspro-nerd-font-mono (...)
Now we just need to pass the result to brew install
:
brew install $( brew search font | grep nerd | tr '\n' ' ' )
Pipes! Composition! Joy!
La voie Unix!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With