I want to compare local folder and folder on server, folder can contain subfolders and subfolders can contain files.
How to compute md5sum for whole folder?
Update:
One possible solution will not to compute hash for whole folder, but to compute hash for each file and then compare lists of hashes.
Lets assume we want to compare folders a
and b
:
tree .
.
├── a
│ ├── 1.txt
│ └── d
│ └── 2.txt
└── b
└── 1.txt
This can show the difference:
find a -type f | sort | xargs md5 -r | cut -f1 -d " " > a.txt
find b -type f | sort | xargs md5 -r | cut -f1 -d " " > b.txt
git diff --no-index a.txt b.txt
But how to check which file corresponds to hash that is missing from one of the folders?
If I
cd a
find . -type f | sort | xargs md5 -r > ../a.txt
cd ..
cd b
find . -type f | sort | xargs md5 -r > ../b.txt
cd ..
git diff --no-index a.txt b.txt
This solves a problem, however maybe not very elegant.
diff
overssh
orrsync
. You really need to usemd5sum
? If so, try the globbing operator:md5sum **
– Pablo Bianchi Nov 15 '19 at 14:27