#!/bin/bash ### rcmp - recursively compare two directories ### Copyright (C) 1999 Arne Zellentin ### This program is free software; you can redistribute it and/or modify ### it under the terms of the GNU General Public License as published by ### the Free Software Foundation; either version 2 of the License, or ### (at your option) any later version. ### This program is distributed in the hope that it will be useful, ### but WITHOUT ANY WARRANTY; without even the implied warranty of ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ### GNU General Public License for more details. ### You should have received a copy of the GNU General Public License ### along with this program; if not, write to the Free Software ### Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ### see http://www.home.unix-ag.org/arne/scripToys/ for details. # # usage: rcmp [-v] # use the "-v" option to have filenames printed as they are compared if [ "$1" = -t ] ; then # tar mode, not really useful. cd "$2" tar cf - . | ( cd - ; cd "$3" ; tar dvf - ) && echo "All OK." && exit 0 echo "Something was wrong.." exit 1 fi flag=/tmp/rcmp.$$.error if rm -f $flag ; then cd . else echo "Trouble cleaning tmp file $flag" exit 1 fi verb=0 if [ "$1" = "-v" ] ; then verb=1 shift fi cd "$2" dest="$PWD" cd - cd "$1" if [ $verb = 1 ] ; then find -type f -print -not -exec cmp '{}' "$dest"/'{}' \; -exec sh -c 'echo "'{}'" >> '$flag \; else find -type f -not -exec cmp '{}' "$dest"/'{}' \; -exec sh -c 'echo "'{}'" >> '$flag \; 2>&1 > /dev/null fi if [ -f $flag ] ; then echo "--------------------------------------------------" echo "The following files do not match their counterparts:" cat $flag exit 1 else echo "All OK." fi