#!/bin/sh

#cache_clean.sh swf
#cache_clean.sh sina.com.cn
#cache_clean.sh zhangyan.jpg

squidcache_path="/usr/local/squid/var/cache"
squidclient_path="/usr/local/squid/bin/squidclient"
grep -a -r $1 $squidcache_path/* | strings | grep "http:" | awk -F’http:’ ‘{print "http:"$2;}’ > cache_list.txt
for url in `cat cache_list.txt`; do
echo "$squidclient_path -m PURGE -p 80 $url"
$squidclient_path -m PURGE -p 80 $url
done

用法:

#cache_clean.sh swf

#cache_clean.sh sina.com.cn

#cache_clean.sh zhangyan.jpg