############################## -*- Mode: sh -*- #############################
## wwwoffle-cache-regexp-rm -- remove things via regular expression from the WWWOFFLE cache
## Copyright       : http://www.fsf.org/copyleft/gpl.html
## Author          : Dan Jacobson -- http://jidanni.org/
## Created On      : July 2001
## Last Modified By: root
## Last Modified On: Thu Jun 13 09:24:47 2002
## Update Count    : 15
## Status          : Use with caution!
###############################################################################
test $# -ne 2 && {
1>&2 cat <<EOF
usage example: $0 http://www.bla.com nardly
will find http://www.bla.com/rrrr/ppppnardlyzzz/qqq
and ask you if you want to delete it from the cache.
Must be root to use, also.
EOF
exit 44;}
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"|more #should put in awk so can check $?...
echo -n 'Delete these from outgoing request list? [n]|y  '
read answer
test x$answer == xy &&
   echo $filelist|xargs -n 1 wwwoffle-rm
   #could also: && if that directory is empty, ask about removing it too...

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

