#!/bin/bash PATH="/bin:/usr/bin" if [ ! -x "$(which sqlite3)" ]; then echo "sqlite3 command not found, install it" exit 1 fi if [ "$(uname -s)" = "Linux" ]; then PROFILE="$(find "$HOME/.mozilla/firefox/" -maxdepth 1 -type d -name '*.default')" elif [ -e "/mach_kernel" -a "$(uname -s)" = "Darwin" ]; then PROFILE="$(find "$HOME/Library/Application Support/Firefox/Profiles" -maxdepth 1 -type d -name '*.default')" else echo "Unknow OS" exit 2 fi if [ ! -d "$PROFILE" ]; then echo "Default profile not found" exit 3 fi VERBOSE=":" #VERBOSE="echo" for SQLITE in $(find "$PROFILE" -maxdepth 1 -name '*.sqlite') do N="$(basename -- "$SQLITE")" BEFORE=$(stat -c %s "$SQLITE") echo "vacuum;" | sqlite3 "$SQLITE" AFTER=$(stat -c %s "$SQLITE") $VERBOSE "$N" $VERBOSE " ($[$[$AFTER*100]/$BEFORE]%) $BEFORE => $AFTER" done