Skip to content

Instantly share code, notes, and snippets.

@dylanroy
Last active June 22, 2016 17:49
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 dylanroy/ecba38a187a6c845204793b5a5af855b to your computer and use it in GitHub Desktop.
Save dylanroy/ecba38a187a6c845204793b5a5af855b to your computer and use it in GitHub Desktop.
Example Usage: histdel.sh www.domain.com
#!/bin/bash
DATABASE=~/Library/Application\ Support/Google/Chrome/Default/History
URL=""
print_usage()
{
printf "usage: `basename $0` URL\n"
exit 1;
}
which sqlite3 >/dev/null
if [ $? -ne 0 ]; then
printf "sqlite3 must be installed before running this script.\n"
exit 1
fi
if [ $# -lt 1 ]; then
print_usage
fi
URL=$1
cat << _EOF_ | sqlite3 $DATABASE
SELECT * FROM urls WHERE url LIKE '%$URL%';
_EOF_
if [ $? -ne 0 ]; then
printf "google-chrome must be terminated before running this script.\n"
exit 1
fi
printf "\nDo you want to delete the above urls? [y/n] "
read foo
if [ $foo != "y" ] && [ $foo != "Y" ]; then
exit 0
fi
printf "deleting..\n"
cat << _EOF_ | sqlite3 $DATABASE
DELETE FROM urls WHERE url LIKE '%$URL%';
_EOF_
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment