I have a script project that checks directories with multiple values and compares them with extended archive files of the same directories elsewhere.
I use it diff -r -q, and I would like for it to diffdetect any difference in the recursive run, it will stop working, and will not go through other directories in the same run.
All help appreciated!
thank
@bazzargh I tried this as you suggested or like this.
for file in $(find $dir1 -type f);
do if [[ $(diff -q $file ${file/#$dir1/$dir2}) ]];
then echo differs: $file > /tmp/$runid.tmp 2>&1; break;
else echo same: $file > /dev/null; fi; done
But this only works with files that exist in both directories. If one file is missing, I will not receive information about it. In addition, in the directories I work with, there are more than 300,000 files, so for each file there is a bit of overhead to do findfor each file, and then diff.
I would like something like this to work, with an instruction elifthat checks to see if $runid.tmpdata contains gaps if that happens. I added 2>after the first statement if, so it is stderrsent to a file $runid.tmp.
for file in $(find $dir1 -type f);
do if [[ $(diff -q $file ${file/#$dir1/$dir2}) ]] 2> /tmp/$runid.tmp;
then echo differs: $file > /tmp/$runid.tmp 2>&1; break;
elif [[ -s /tmp/$runid.tmp ]];
then echo differs: $file >> /tmp/$runid.tmp 2>&1; break;
else echo same: $file > /dev/null; fi; done
Will this work?
source
share