Wednesday, October 31, 2007

Development Grep Wrapper Script

This is a cute little script I wrote on my friend Sean's suggestion. Basically it performs a grep -r on a directory which you specify, and then trims out any Binary Swap matches, any subversion responses, and any compiled smarty template responses. It will then open the resulting values in vim. Perfect for the LAMP developer.

This bad boy takes 3 arguments:


  1. Regular Expression (no spaces . . . or bounded by double quotes)

  2. Direcory to search on

  3. Ouput file




#!/bin/bash
###############################################
## grepSVN.sh
## Script that grep -r a directory and removes all unwanted mateches
## (svn and binary swap files, and also compiled smarty templates)
##
## Author: Matthew Story
## Date: 10/31/2007
## All Contents Released Under the LGPL v1.0
###############################################
grep -r ${1} ${2} | sed s/^.*[.]svn.*$//g | sed s/^Binary[[:space:]]*file.*$//g | sed s/^.*templates_c.*$//g > ${3}
vim -c "%s/^$\n//g" ${3}

No comments: