Skip to content

Instantly share code, notes, and snippets.

@Coornail
Created November 5, 2012 07:57
Show Gist options
  • Save Coornail/4015909 to your computer and use it in GitHub Desktop.
Save Coornail/4015909 to your computer and use it in GitHub Desktop.
Chrome sqlite vacuum on OsX
#!/bin/sh
DIRECTORY='~/Library/Application Support/Google/Chrome/'
TMPFILE=`mktemp /tmp/chrome_cleanup.XXXXXX`
find "$DIRECTORY" >> $TMPFILE
SQLITE_FILES=`mktemp /tmp/chrome_cleanup.XXXXXX`
SAVEIFS=$IFS
IFS=$'\n'
for i in $(cat $TMPFILE); do
file "$i" | grep 'SQLite' | cut -d ':' -f1 >> $SQLITE_FILES;
done
for i in $(cat $SQLITE_FILES); do
echo "[ ] $i"
SIZE_BEFORE=`du -sh "$i" | cut -s -f1`
sqlite3 "$i" "VACUUM;"
SIZE_AFTER=`du -sh "$i" | cut -s -f1`
echo "[+] $SIZE_BEFORE -> $SIZE_AFTER"
done
IFS=$SAVEIFS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment