Created
November 22, 2017 20:44
-
-
Save bennylope/c7969c33eea835930f977cbaf40adb03 to your computer and use it in GitHub Desktop.
A short script for performing brew cleanup for all but specified packages. The 'cleanup' command can either be used for specific packages or for all - there is no exclusion option - and this means cleanup on older packages that I want.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Clean all but specified packages of old homebrewed installed packages | |
declare -a exclude=(python python3 python34 python35 python36 python27 pypy ruby node) | |
for PACKAGE in $(brew ls) | |
do | |
SENTINEL=false | |
for EXCLUDE in "${exclude[@]}" | |
do | |
if [ "$PACKAGE" = "$EXCLUDE" ]; then | |
SENTINEL=true | |
fi | |
done | |
if [ "$SENTINEL" = false ] ; then | |
echo "Cleaning up $PACKAGE" | |
brew cleanup $PACKAGE | |
else | |
echo "Skipping cleanup on $PACKAGE" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment