brew list --formula | xargs -n1 -P8 -I {} \ | |
sh -c "brew info {} | egrep '[0-9]* files, ' | sed 's/^.*[0-9]* files, \(.*\)).*$/{} \1/'" | \ | |
sort -h -r -k2 - | column -t |
Thanks, it worked for me too.
Me too, thank you!
This is really slow, is there something faster?
@Coldsp33d here's how to do it in parallel; note that you need parallel
which you can install with brew install parallel
. (Sorry, I couldn't figure out how to do this with xargs
. 😬 )
brew list -f1 | parallel "brew info {} | egrep '[0-9]* files, ' | sed 's/^.*[0-9]* files, \(.*\)).*$/{} \1/'"
Can also do this to sort by size descending, though you won't see intermediate output while parallel goes:
brew list -f1 | parallel "brew info {} | egrep '[0-9]* files, ' | sed 's/^.*[0-9]* files, \(.*\)).*$/{} \1/'" | sort -h -r
Just a small update, the sorting command is not correct at least for me
brew list -f1 | parallel "brew info {} | egrep '[0-9]* files, ' | sed 's/^.*[0-9]* files, \(.*\)).*$/{} \1/'" | sort -k2 -hr
Sorts correctly because we are sorting the second column
I didn't want to require parallel dependency so I've updated the snippet to use xargs, added the sort and table output. Thanks for the suggestions everyone.
thank you so much!
Just a small update, the sorting command is not correct at least for me
brew list -f1 | parallel "brew info {} | egrep '[0-9]* files, ' | sed 's/^.*[0-9]* files, \(.*\)).*$/{} \1/'" | sort -k2 -hr
Sorts correctly because we are sorting the second column
Hi @NikhilVerma i tried your command and even others above but its failing for me
Error: ambiguous option: -f1
Am on macOS catalina 10.15.6 with CLT 11.5.0.0.1.1588476445.
Pls help out
Hi @NikhilVerma i tried your command and even others above but its failing for me
Error: ambiguous option: -f1Am on macOS catalina 10.15.6 with CLT 11.5.0.0.1.1588476445.
Pls help out
@jagdishadusumalli Remove -f1 after brew list.
Hi @NikhilVerma i tried your command and even others above but its failing for me
Error: ambiguous option: -f1
Am on macOS catalina 10.15.6 with CLT 11.5.0.0.1.1588476445.
Pls help out@jagdishadusumalli Remove -f1 after brew list.
Thanks Vasudev
I've removed -f1
from the gist, thanks @vasudev-hv and @jagdishadusumalli
Warning: Calling
brew list
to only list formulae is deprecated! Usebrew list --formula
instead.
Added --formula
Just an updated version for simpletons like me
brew install parallel; parallel --citation #Skip this step if parallel is already installed
brew list --formula | parallel "brew info {} | egrep '[0-9]* files, ' | sed 's/^.*[0-9]* files, \(.*\)).*$/{} \1/'" | sort -k2 -hr
This is identical to what @bkeys818 posted except it's compatible with the fish
shell
brew install parallel; parallel --citation #Skip this step if parallel is already installed
brew list --formula | parallel "brew info {} | egrep '[0-9]* files, ' | sed 's/^.*[0-9]* files, \(.*\)).*(/{}) \1/'" | sort -k2 -hr
Alternative: brew install ncdu && ncdu /opt/homebrew/Cellar
Works on fish
shell without parallel
:
brew list --formula | xargs -P8 -I {} sh -c "brew info {} | grep -E '\([0-9]+ files'" \
| awk -F '[/(),]' '{print $6 ", " $8 ", " $9}' | sort -t "," -rh -k3
and gives output in a comma-separated format which can be simply changed in the awk command:
exiftool, 603 files, 25.3MB
micro, 7 files, 11.4MB
tealdeer, 12 files, 5.4MB
bat, 14 files, 4.6MB
eza, 14 files, 1.1MB
thanks, this helped, if you could format it to a table that would make it a lot better