Last active
February 17, 2016 02:09
-
-
Save calum-github/3bd5a0a26b76a0113c5b to your computer and use it in GitHub Desktop.
Remove old autopkg receipts plist
This file contains hidden or 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
| #!/bin/bash | |
| ########################################################## | |
| # Date: 17-02-2016 # | |
| # Author: Calum Hunter # | |
| # Version: 0.1 # | |
| # Purpose: Remove receipt plists from autopkg cache # | |
| # after $x days # | |
| ########################################################## | |
| # Get a list of directories in the cache folder and store them in an array | |
| shopt -s nullglob | |
| AUTOPKG_RECIPE_DIRS=(~/Library/AutoPkg/Cache/*) | |
| # Number of days to wait before removing a receipt plist | |
| DAYS="7" | |
| for RECIPE in "${AUTOPKG_RECIPE_DIRS[@]}"; do | |
| if [ -d "$RECIPE" ]; then | |
| echo "" | |
| echo "- Found cache folder for recipe: $RECIPE" | |
| echo " - Locating receipts that are older than $DAYS days" | |
| NUM_RECEIPTS=$(find "${RECIPE}"/receipts/ -type f -mtime +"$DAYS" -print | wc -l) | |
| echo " - Found $NUM_RECEIPTS files that need to be removed" | |
| echo " - Removing receipts...." | |
| find "${RECIPE}"/receipts/ -type f -mtime +"$DAYS" | xargs rm | |
| echo "- Complete!" | |
| fi | |
| done | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment