Thursday, August 13, 2009

diffdir

One thing Solaris does nicely is let you find the differences between directories and show 'em side by side so you can figure out what files are where.

I'm using Ubuntu (and Bash, like normal) and need to find a dir diff showing files in one dir and not in another, etc .

this is simply the command diff -q -r dir1 dir2.

However, I'm using source controlled directories, so this shows up with a whole mess of gall-durn .svn directories, etc. So I need to filter this out and an alias won't work.

Here's the code for my dirdiff or diffdir bash script:


#!/bin/bash
#--verbose
if (!(test -d $1))
then
echo "bad dir 1";
exit;
fi
if (!(test -d $2))
then
echo "bad dir 2";
exit;
fi
out=`diff -q -r $1 $2 | egrep -v svn `;
# echo "Result of diff: $out";
if [ -z "$out" ]
then
echo "Same";
else
echo "Difference between $1 and $2: "
echo "$out"
fi
# echo "Done";


No comments: