Re: diff files matching a pattern
On Sun, Feb 24, 2008 at 02:21:56PM -0500, Kamaraju S Kusumanchi wrote:
> Let's say I have two directories dir1, dir2 each with 1000 files.
> Of these 1000 files in each directory, there are 50 files named file1.txt,
> file2.txt ... file50.txt. The rest of the files do not follow any pattern
> and are very large in size.
>
> Now is there any way to compare
>
> dir1/file1.txt and dir2/file1.txt
> dir1/file2.txt and dir2/file2.txt
> ....
> dir1/file50.txt and dir2/file50.txt
Something like:
#!/bin/bash
myday=`date +%y%m%d`
outfile="diff-check-$myday"
for f in `ls $1` ; do
if [ -f $2/$f ] ; then
echo file $f >> $outfile
echo "----------------" >> $outfile
diff $1/$f $2/$f >> $outfile
echo "================" >> $outfile
fi
done
(untested) but it ought to do it. Well, it's a starting point. Save it as
~/bin/diff-check where ~/bin is on your path, and chmod u+x. Call it like this
'diff-check dir1 dir2' and its results will be in the directory from which you
called it.
HTH
--
richard
Reply to: