Today's snazzy ack trick

petdance on 2007-08-25T03:56:24

I'm going through a codebase that's got a ton of unused files that have never been pruned. I use ack to look to see if a given file is used, and if not, svn rm the sucker. Then the domino effect starts. Removing that file means that there may well be others, both HTML and graphic, that are no longer used, too. Here's my handy tool to make that easier:

svn diff | grep ^- | ack '(href|src)="(.+?)"' --output='$2' | sort -u
Get the diff, only look at the lines where something's been removed, then find href= or src=, and only show what's in the parens, then sort and dedupe. Voila!