############################## -*- Mode: sh -*- #############################
## wwwoffle-cache-regexp-rm -- remove things via regular expression from the WWWOFFLE cache
## Author          : jidanni == Dan Jacobson
## Created On      : July 2001
## Last Modified By: root
## Last Modified On: Wed Oct 24 08:21:22 2001
## Update Count    : 6
## Status          : Use with caution!
###############################################################################

# The newest copy of this program is on
# http://www.geocities.com/jidanni/wwwoffle-jidanni.html

test $# -ne 2 && { echo $0: usage example: $0 http://www.bla.com regexp 1>&2; exit 44;}
#Must be root to use, also.

set -e
filelist=`wwwoffle-ls "$1"|awk '
{a=$6; sub("'$1'","",a); if (a ~ "'$2'") {print $6 | "sort";flag=1}}
	    END{if (!flag){print "'$0': no matches" > "/dev/stderr" ;exit 1}}'`
echo "$filelist"
echo -n 'Delete these from outgoing request list? [n]|y  '
read answer
test x$answer == xy &&
 echo $filelist|xargs -n 1 wwwoffle-rm

# too bad wwwoffle-ls can't do this
#wwwoffle-ls http://www.geocitiles.com/certian_user
#to see their whole tree, or
#wwwoffle-ls http://www.geocitiles.com/certian_user/some_regexp...
#ok, anyway...

