[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: diff files matching a pattern

On Sun, Feb 24, 2008 at 03:12:34PM -0500, Kamaraju S Kusumanchi wrote:

> Tzafrir Cohen wrote:
> > 
> > LC_ALL=C diff -r dir1 dir2 | grep -v ^Only
> > 
> > The size really doesn't matter for those extra large files.
> > 
> This works only if the extra 950 files are in just one directory. If the
> extra files are there in both the directories, then it does not make sense
> to compare all the 1000 files since I am interested only in the diff of 50
> files.

I hadn't realized the other files were also repeated in both
directories.  I also had a couple of typos/bugs in the script I
suggested earlier.  This allows you to filter on a pattern with
wildcards, and seems superficially to work:
# usage: diff-check dir1 dir2 "pattern"
# pattern must be in double quotes to avoid shell expasion
myday=`date +%y%m%d-%H:%M`
for f in `ls $1/$3` ; do
  if [ -f $2/$fname ] ; then
    echo checking file $fname
    echo $fname in $1, $2 >> $outfile
    echo "----------------" >> $outfile
    diff $1/$fname $2/$fname >> $outfile
    echo "================" >> $outfile
    nr=$((co ++))
echo $co files compared.

Adjust to taste



Reply to: