Last active
June 22, 2016 17:49
-
-
Save dylanroy/ecba38a187a6c845204793b5a5af855b to your computer and use it in GitHub Desktop.
Example Usage: histdel.sh www.domain.com
This file contains hidden or 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
#!/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