Apple - How can I install all brew packages listed in a text file?

xargs brew install < brew.txt

No need to cat the file (see Useless Use of Cat Award) and xargs instead of a for loop to avoid IFS.


You can do brew leaves > my_brews.txt and then on the new machine do for i in $(cat brew_leaves); do; brew install "$i"; done. You can use newlines where there are semicolons above. [assuming bash]


MERM provided a working answer, but others may be interested in a solution that, while not included with Homebrew, is published by the same people. Homebrew bundle is a brew package that is designed for this purpose, also handling casks and, I think, Mac App Store apps (with the mas package).

Tags:

Homebrew