In OSX or Linux, how can I easily compare a path Foo and a path Bar and get a list of ALL files and folders that are different between them?
It would also be handy to get a number of KB of total difference between the two paths.
My use case is that I want to verify that path A was completely copied to path B, and I'm certain that there will be very small differences due to different capabilities of the underlying FS types, so I need a tool/script that will do more than just tell me "yes" or "no".
Since you want to copy files from folder A to folder B, you know that folder B might be missing files (not folder A), you could then loop over all files in folder A and check if they have the same size in folder B. Something like
#!/bin/bash
for file in `ls A`
do
# check if file exists
if [ -e B/"${file}" ]
then
fileSize1=`stat -c%s A/"${file}"`
fileSize2=`stat -c%s B/"${file}"`
if [ ${fileSize1} -ne ${fileSize2} ]
then
echo "The files ${file} have not the same size."
fi
else
echo "The file ${file} does not exist."
fi
done
Of course you have to be careful with subdirectories.
Option 1
You can simply use diff
diff -qr dir1 dir2
You can also play with --exclude
and the many other options.
Option 2
You can use another GUI tool like Meld (or maybe Midnight-Commander on console)
Sources: the 1st 2 answers i found in duckduckgo
Related:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With