Created
April 24, 2021 03:35
-
-
Save nberlette/15224b333e7e92e0074b4bb285bc5c29 to your computer and use it in GitHub Desktop.
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
## Purge macOS Time Machine's Local Snapshots | |
## By Nicholas Berlette <github.com/nberlette> | |
## Usage: | |
## purge_local_snapshots [-q|--quiet] | |
function purge_local_snapshots() { | |
quiet=$(echo ${1,,} | grep "\-q") | |
snapshots=$(tmutil listlocalsnapshotdates | grep "-") | |
if [[ "${#snapshots}" -eq "0" ]]; then | |
[[ "${#quiet}" -eq "0" ]] && echo "No snapshots available!"; return; | |
else | |
i=1 | |
ns1=$(date +"%N") | |
for d in $snapshots; do | |
ns2=$(date +"%N") | |
sudo tmutil deletelocalsnapshots $d && { [[ "${#quiet}" = "0" ]] && echo "#$i. $d ($(($ns2-$ns1)) nsec)"; } | |
i=$(($i+1)) | |
done | |
fi | |
} | |
## pass $* so this can be run as a file | |
purge_local_snapshots "$*" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment