I recently moved from Firefox to Safari after upgrading to Tiger. One thing I missed was the ability to 'sanitize' (clear history, cache, cookies, saved searches etc.) my browser. Although Safari has a Private Browsing, feature I prefer the following method, which lets me keep my cache, history, and cookies until I want them gone, instead of not creating them in the first place.
I'm new to both the UNIX shell and AppleScript, but managed to create this simple AppleScript which executes a shell script. As you can see, it deletes the current user's Safari cache folder, cookies file, history and download history file. It also deletes the recent Google searches from Safari's preferences file.
try
do shell script "rm -r ~/Library/Caches/Safari
~/Library/Cookies/Cookies.plist ~/Library/Safari/Downloads.plist
~/Library/Safari/History.plist ;
defaults delete com.apple.safari RecentSearchStrings"
end try
Note: The do shell script line has been broken into four lines here for narrower display. Make it one line only, with a space replacing each line break.
Mac OS X Hints
http://hints.macworld.com/article.php?story=20051107093733174