binary compare two directories


/ Published in: Perl
Save to your folder(s)



Copy this code and paste it in your HTML
  1. #!/usr/bin/perl -w
  2.  
  3. $CMP="/usr/bin/cmp";
  4.  
  5. $dir0=$ARGV[0];
  6. $dir1=$ARGV[1];
  7.  
  8. if(!$dir0 || !dir1){ print "Error: need both directory paths to compare";exit;}
  9.  
  10. @files0=`find $dir0 -type f`;
  11. $count=0;
  12. foreach $file0 (@files0){
  13. $file1=$file0;
  14. $file1=~s/$dir0//;
  15. $file1=$dir1.$file1;
  16. chomp($file0);
  17. chomp($file1);
  18. $file0=~s/\$/\\\$/;
  19. $file1=~s/\$/\\\$/;
  20. system("$CMP $file0 $file1");
  21. if($count>10){
  22. print ".";
  23. $count=0;
  24. }else{
  25. $count++;
  26. }
  27. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.