Posted By

rm1984 on 10/15/16


Tagged

Shell Bash Firefox history mozilla sh SQLite sqlite3


Versions (?)

Firefox history stats with Bash


 / Published in: Bash
 

URL: https://raymii.org/s/snippets/Firefox_History_Stats_with_Bash.html

This is a small script to gather some statistics from your Firefox history. First we use sqlite3 to parse the Firefox history database and get the last three months, then we remove all the IP addresses and port numbers and finally we sort and count them.

  1. #!/bin/bash
  2.  
  3. if [[ ! -d ${HOME}/.www ]]; then
  4. mkdir ${HOME}/.www
  5. fi
  6.  
  7. cp "$(find "${HOME}/.mozilla/firefox/" -name "places.sqlite" | head -n 1)" "${HOME}/.www/places.sqlite"
  8. sqlite3 "${HOME}/.www/places.sqlite" "SELECT url FROM moz_places, moz_historyvisits WHERE moz_places.id = moz_historyvisits.place_id and visit_date > strftime('%s','now','-3 month')*1000000 ORDER by visit_date;" > "${HOME}/.www/urls-unsorted"
  9. sort -u "${HOME}/.www/urls-unsorted" > "${HOME}/.www/urls"
  10. awk -F/ '{print $3}' "${HOME}/.www/urls" | grep -v -E -e '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' -e ':.*' -e '^$' | sed -e 's/www\.//g' |sort | uniq -c | sort -n

Report this snippet  

You need to login to post a comment.