Last active
May 25, 2016 13:01
-
-
Save ZaWertun/0cb56a076d8acab05f1d92ad82412338 to your computer and use it in GitHub Desktop.
Clears Firefox history older than 30 days
This file contains 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
#!/usr/bin/env bash | |
# Clears Firefox history older than 30 days | |
function clear_history() { | |
local db=$1 | |
local visits="moz_historyvisits v, moz_places p where v.place_id = p.id and p.id not in (select distinct(fk) from moz_bookmarks) and v.visit_date < strftime('%s', 'now', '-30 day') * 1000000" | |
local count=$(echo "select count(*) from $visits;" | sqlite3 $db) | |
if [ $count -gt 0 ]; then | |
echo "$count history items will be deleted from $i" | |
echo "delete from moz_historyvisits where id in (select v.id from $visits);" | sqlite3 $db | |
fi | |
} | |
find ~/.mozilla/firefox -name places.sqlite -print0 | while IFS= read -r -d $'\0' i; do | |
clear_history $i | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment