Permalink
Browse files

added search and delete bash script

  • Loading branch information...
1 parent 29559ee commit 76d4ef9754205597fa3c8d070af41f1e2652c7e9 @coolaj86 coolaj86 committed May 2, 2012
Showing with 30 additions and 0 deletions.
  1. +30 −0 clients/dropshare-delete.sh
@@ -0,0 +1,30 @@
+SEARCH=$1
+if [ -z "${SEARCH}" ]
+then
+ echo 'Usage: dropshare-delete <search-term>'
+ echo 'You will be asked for confirmation before deleting files and db entries'
+ exit 1
+fi
+
+KEYS=`redis-cli keys '*'`
+for KEY in $KEYS
+do
+ JSON=`redis-cli GET $KEY`
+
+ if [ -z `echo $JSON | grep -i "${SEARCH}"` ]
+ then
+ continue
+ fi
+
+ echo "$KEY: "
+ echo $JSON | python -mjson.tool
+ echo "Delete '$KEY'? [N/y]"
+ read YN
+
+ if [ "$YN" == "y" ]
+ then
+ SHA1=`echo $JSON | python -mjson.tool | grep sha1checksum | cut -d'"' -f4`
+ rm "files/${SHA1}"
+ redis-cli DEL "$KEY"
+ fi
+done

0 comments on commit 76d4ef9

Please sign in to comment.