How to compare filesystem contents

Mogens Kjaer mk at crc.dk
Fri May 7 10:18:59 UTC 2010


On 05/07/2010 11:05 AM, Andrew Junev wrote:
...
> Is there an easy way to check which files are there on the old
> filesystem, that do not exist on the new one?

cd /newdisk
find . -type f | sort >/tmp/newdisk.lst
cd /olddisk
find . -type f | sort >/tmp/olddisk.lst

diff /tmp/olddisk.lst /tmp/newdisk.lst

If you want to check if files are identical, you can do:

cd /newdisk
find . -type f -exec md5sum "{}" \; | sort >/tmp/newmd5.lst
cd /olddisk
find . -type f -exec md5sum "{}" \; | sort >/tmp/oldmd5.lst
diff /tmp/newmd5.lst /tmp/oldmd5.lst

The two lists need to be sorted as the
file order might be different between the
two file systems.

Maybe cp had problems recognizing sparse files
correctly?

Mogens
-- 
Mogens Kjaer, Carlsberg A/S, Computer Department
Gamle Carlsberg Vej 10, DK-2500 Valby, Denmark
Phone: +45 33 27 53 25, Mobile: +45 22 12 53 25
Email: mk at crc.dk Homepage: http://www.crc.dk


More information about the users mailing list