about:benjie

Random learnings and other thoughts from an unashamed geek

Useful Bash Scripts

| Comments

Bash

Here’s a couple of bash scripts I’ve written recently that might be of use to someone. They work well under Ubuntu, and should work under any GNU/Linux or Unix system with the suitable software installed. Improved “svn diff” command (ignores whitespace “Whitespace (computer science)”), colour highlights output, requires colordiff) - I put it in /usr/local/bin/svndiff:

/usr/local/bin/svndiff - ‘svn diff’ but coloured and ignoring whitespace
1
2
#!/bin/bash
svn diff -x -w [email protected] | colordiff

Improved recursive grep command (greps recursively, ignores files in the .svn folders, ignores temporary files, highlights output in colour) - I put it in /usr/local/bin/grepr:

/usr/local/bin/grepr - recursive grep with colour highlights and excluding temporary files and .svn directories.
1
2
3
4
#!/bin/sh
SEARCHTERM=$1;
shift;
find . -type f -a -not -iname "*~" -a -not -iwholename "*/.svn/*" -exec grep -H --color=auto [email protected] "$SEARCHTERM" "{}" \;

You might also be interested in my previous “whoops I deleted files without telling svn” post here.

Comments