How to Search Your Mozilla Cache
Ever want to look for something in your browser cache, but when you go there, it's just a mass of oddly named files and you can't figure out how to find anything?(Sure, for whole pages you can use the History window, but what if you just want to find an image you saw this morning that isn't there any more?)
Here's a handy trick.
First, change directory to your cache directory (e.g. $HOME/.mozilla/firefox/blahblah/Cache).
Next, list the files of the type you're looking for, in the order in which they were last modified, and save that list to a file. Like this:
% file `ls -1t` | grep JPEG | sed 's/: .*//' > /tmp/foo
In English: ls -t lists in order of modification date, and -1 ensures that the files will be listed one per line. Pass that through grep for the right pattern (do a file * to see what sorts of patterns get spit out), then pass that through sed to get rid of everything but the filename. Save the result to a temporary file.
The temp file now contains the list of cache files of the type you want, ordered with the most recent first. You can now search through them to find what you want. For example, I viewed them with Pho:
pho `cat /tmp/foo`For images, use whatever image viewer you normally use; if you're looking for text, you can use grep or whatever search you lke. Alternately, you could ls -lt `cat foo` to see what was modified when and cut down your search a bit further, or any other additional paring you need.
Of course, you don't have to use the temp file at all. I could have said simply:
pho `ls -1t` | grep JPEG | sed 's/: .*//'`Making the temp file is merely for your convenience if you think you might need to do several types of searches before you find what you're looking for.
[ 22:40 Oct 10, 2005 More tech/web | permalink to this entry | ]