Redirecting formula list files into brew for batch bash operations


(Casper S) #1

So, I have a bit of a problem. I’ve done the following:

"brew list > “~/Documents/brewInstalledList.txt”

My idea was that if I reformat my Mac or get a new system, I can very quickly get all my packages back, by simply running

“cat [file] | brew install”

However, this doesn’t work. Brew complains it’s not receiving formulas as input. I know brew install can take more than one package per call, so why can’t it parse them from cat?
And are there any workarounds?

Thanks :slight_smile:


(Jonathan Chang) #2

You might need to do something like

brew install $(cat myfile.txt)

as I don’t think brew install knows to read from standard input.

For another solution to your issue check out Brewfile: https://github.com/Homebrew/homebrew-bundle


(Casper S) #3

Thank you so much! Though quite frankly, I thought that whatever I wrote in the Terminal and stdin was the exact same thing?

Regardless, your solution works, and I’m grateful :slight_smile: