Using grep, awk and sed to list files containing a string

This week I was trying to locate which files in the codebase use a specific class method while debugging some code. This method however has been used a lot, when I say a lot I mean 10 to 20 times per file, and in lots of templates. This is mainly because it is a template helper to generate complex links within the page. Anyway, a simple use of grep wasn’t all that much help, so I refreshed my memory on how to use sed to make the output a little more readable.

Continue reading Using grep, awk and sed to list files containing a string

Magic 8-ball written in bash

Have you ever wanted a magic 8ball to use at work? A real one, even though nice to have on your desk, is not always practical. When I had a real one on my desk people were forever playing with it when they came to talk to me.

Making one is very simple. All you need is an array of values to use as responses, and a way to pick one of them at random. I could have written this in any number of languages, but this one is written in bash for simplicity.

Continue reading Magic 8-ball written in bash

Time saving tricks with svn and grep

SubVersionWe’ve all been there, you’re working on a project with lots of externals and we see a lot of noise when you run svn status or svn st (depending on your preference). Most of the time we just filter that out, but I decided to string a few grep statements together to make the output that little bit nicer to read.

Continue reading Time saving tricks with svn and grep

Tricks with SVN and Brace Expansion

SubVersionThere are loads of little tips and tricks out there on how to make your svn operations a little easier. One which I found out recently was how to leverage bash’s brace expansion to reduce key strokes.

Brace expansion definition

This powerful feature makes svn diff commands a lot easier.

Continue reading Tricks with SVN and Brace Expansion