1

Tip #480   Diff Two Directories

A quick script to compare files from two directories (for example a backup and working directory).

#!/bin/bash

cr='*'
if [ -z $3 ]; then cr=$3; fi

for f in `find $1/$3 -type f | sed "s|$1/||"`
do
  printf "===!%-76s" "$f!" | tr ' !' '= '; echo
  diff $1/$f $2/$f | sed -e "s/^</$1: /" -e "s/^>/$2: /"
done


Usage: [script name] directory1 directory2 to check all files
[script name] directory1 directory2 *html to check files of type html.