Created
July 26, 2023 19:07
-
-
Save Juma7C9/61d09aa8c4b1ec51f9d43a8c272a34a0 to your computer and use it in GitHub Desktop.
Simple script to delete pacman package files older than some period, printing the freed space
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 | |
CACHE_PATH=/var/cache/pacman/pkg | |
PRESERVE_MONTHS=3 | |
DELETED_SIZE=$(/usr/bin/find . ! -newermt "$PRESERVE_MONTHS months ago" -ls | awk -F' ' 'BEGIN {sum=0} {sum+=$7} END {print sum}' | numfmt --to=iec-i)B | |
/usr/bin/echo "Deleting $DELETED_SIZE of package files older than $PRESERVE_MONTHS months..." | |
/usr/bin/find $CACHE_PATH ! -newermt "$PRESERVE_MONTHS months ago" -delete |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment