Skip to content

Instantly share code, notes, and snippets.

@philpennock
Created April 19, 2017 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philpennock/25ec5e31a8709864bce344c8a1123a56 to your computer and use it in GitHub Desktop.
Save philpennock/25ec5e31a8709864bce344c8a1123a56 to your computer and use it in GitHub Desktop.
#!/bin/sh -eu
set -eu
clean_here() {
find . -type f -execdir sh -c \
'f="{}";
t=$(file -hb "$f");
[ "$t" = "SQLite 3.x database" ] || exit 1;
printf "%s/%s\n" "$(pwd)" "$f";
ls -ld 2>/dev/null "$f" "${f}-journal";
sqlite3 "$f" "vacuum full;";
ls -ld 2>/dev/null "$f" "${f}-journal";
echo
' \;
}
[ $# -eq 0 ] && set \
"${HOME:?}/Library/Application Support/Google/Chrome" \
"${HOME:?}/Library/Application Support/Slack"
for DIR; do
cd "$DIR"
clean_here
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment