Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get size of each installed formula in homebrew? [closed]

Tags:

macos

homebrew

I would like to find the size of my installed brew packages so I can see how much space each is taking up. How do I go about doing this from the terminal?

Note: some of the answers below also include brew cask packages which is also very helpful to this answer.

like image 555
shyamupa Avatar asked Oct 15 '16 23:10

shyamupa


People also ask

How much MB is homebrew?

In order to install Homebrew, you need to install either the Xcode Command Line Tools (about 100 MB) or the full Xcode package (about 10 GB). In this tutorial, you will install Command Line Tools as they are a more reasonable size. Command Line Tools gives Mac users many commonly used tools, utilities, and compilers.

Where does Homebrew install packages Linux?

Homebrew installs files to /home/linuxbrew/. linuxbrew/bin/ by default, so they won't interfere with future Linux updates.

What is Homebrew Formulae?

Homebrew Formulae is an online package browser for Homebrew. It displays all packages in the Homebrew/homebrew-core and Homebrew/homebrew-cask. A GitHub Action is run periodically which pulls changes from each tap and deploys the site to GitHub Pages.

Where does brew install packages on Mac?

On Mac Intel, Homebrew installs itself into the /usr/local/bin directory, which is already configured for access by the shell with the macOS default $PATH environment variable (the default is set by the /usr/libexec/path_helper command).


2 Answers

riffing off of PTao's solution, here's an ugly improved version which will include a human-readable sum of the combined sized of all package versions

for pkg in `brew list --formula -1 | egrep -v '\.|\.\.'`   do echo $pkg `brew info $pkg | egrep '[0-9]* files, ' | sed 's/^.*[0-9]* files, \(.*\)).*$/\1/' | awk '{print $1;}/[0-9]$/{s+=$1};/[mM][bB]$/{s+=$1*(1024*1024);next};/[kK][bB]$/{s+=$1*1024;next} END { suffix=" KMGT"; for(i=1; s>1024 && i < length(suffix); i++) s/=1024; printf "\t(all versions: %0.1f%s)",s,substr(suffix, i, 1), $3; }'` done 

example output:

ack 173.5KB 178.4KB 182.7KB 190.5KB (all versions: 725.1K) afl-fuzz 556.5KB 561.3KB (all versions: 1.1M) aircrack-ng 934.2KB 953KB (all versions: 1.8M) autoconf 1.9MB (all versions: 1.9M) autojump 325.4KB (all versions: 325.4K) automake 2.9MB 3.0MB 3MB (all versions: 8.9M) bash-completion 608.6KB (all versions: 608.6K) boost 414.6MB 398.7MB (all versions: 813.3M) cairo 5.9MB 5.9MB (all versions: 11.8M) cask 166.6KB (all versions: 166.6K) cmake 31.4MB (all versions: 31.4M) coreutils 8.5MB 7.9MB 9MB (all versions: 25.4M) curl 3MB (all versions: 3.0M) dos2unix 344.4KB 360.5KB (all versions: 704.9K) ebook-tools 69.6KB 70.5KB (all versions: 140.1K) eigen 3.5MB 6.5MB (all versions: 10.0M) 
like image 189
Chris Avatar answered Oct 04 '22 19:10

Chris


It's not exceedingly pretty, but you can do

$ brew list --formula | xargs brew info 

And it will output something along the lines of

... /usr/local/Cellar/ant/1.9.6 (1,611 files, 34.8M)   Poured from bottle on 2016-03-31 at 09:35:41 /usr/local/Cellar/ant/1.9.7 (1,611 files, 34.9M) *   Poured from bottle on 2016-12-15 at 09:58:56 .. 

for each package you have installed. I'm sure some wizard with grep could make this give you a nice table if you have many taps installed.

like image 30
ahagen Avatar answered Oct 04 '22 18:10

ahagen