środa, 14 lutego 2018

How to compare folders

1. diff -rq folder1 folder2
-r - means recursive
-q - means give only differences

2. rsync -n -avrc /abc/home/sample1/* server2:/abc/home/sample2/
https://stackoverflow.com/a/19410791
rsync -n -avr --size-only --delete /abc/home/sample1/ server2:/abc/home/sample2/


3. using "meld".
It is slow, but graphical interface

4. using "find"
A good way to do this comparison is to use find with md5sum, then a diff.
Example:
Use find to list all the files in the directory then calculate the md5 hash for each file and pipe it to a file:
find /dir1/ -type f -exec md5sum {} \; > dir1.txt
Do the same procedure to the another directory:
find /dir2/ -type f -exec md5sum {} \; > dir2.txt
Then compare the result two files with "diff":
diff dir1.txt dir2.txt
This strategy is very useful when the two directories to be compared are not in the same machine and you need to make sure that the files are equal in both directories.
 https://stackoverflow.com/questions/16787916/difference-between-two-directories-in-linux

Brak komentarzy:

Prześlij komentarz