Today's snazzy ack trick

brian_d_foy on 2007-08-25T06:47:00

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!


Woot!

Ovid on 2007-08-25T10:54:33

This almost makes me wish I wasn't off work for a week :)