Answer the question
In order to leave comments, you need to log in
Script (or program) to compare data in two directories?
Hello!
There are a bunch of files that are packed into an archive on one machine, and transferred to another, unpacked on it, but if you look at the original and already unpacked files, the size of the folders (du -s folder) are different! Therefore, I decided to try to write the following script:
#!/bin/bash
DIR1=New
DIR2=New1
CAC="sha512sum"
IFS=$'\n' array0=( $(find "$DIR1" -type f ) )
IFS=$'\n' array1=( $(find "$DIR2" -type f) )
#echo ${array0[@]}
for rec0 in ${array0[@]}; do
#echo `$CAC $rec0`
IFS=$'\n' c0=( $($CAC $rec0) )
#echo ${c0[@]}
done
for rec1 in ${array1[@]}; do
IFS=$'\n' c1=( $($CAC $rec1) )
#echo ${c1[@]}
done
#for rec2
#if ; then
#echo 'su';
#else
#echo 'e';
#fi
#for t in ${c0[@]; do
#for b in ${c1[@]; do
#if ; then
#echo 'right'
#else
#echo 'left'
#fi
Answer the question
In order to leave comments, you need to log in
DU does not show the size of files and folders, but how much they occupy on the disk.
For example, if you have a larger block size on the second disk, then du will always show more.
In your case, it's better to synchronize everything via rsync with compression - more reliable. And in general, there are many ready-made solutions for synchronizing two directories that have already taken care of all childhood illnesses, such as file names with dangerous characters, and other things.
You can also do one-way synchronization.
Or simplify the script, for example to this
find DIR1/* -exec md5sum {} \; > file1.lst
find DIR2/* -exec md5sum {} \; > file2lst
diff file1.lst file2.lst
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question