I wrote one of these for fun a while back using the following approach:<p>- Files are indexed by inode and device, files with the same inode + device are considered equal. (My main use case for this was to bundle up JS files.)<p>- Files are then indexed by size; only files with the same size are compared.<p>- During comparison, the files are read at block sizes increasing in powers of two, starting with 2k. The blocks are hashed and compared, and if they do not match the comparison is stopped early (often without having to read the full file). If all the hashes are equal, then the files are considered to be equal.<p>- Hashes are only computed when needed and cached in memory. Since the hash block size increases in powers of two, only a few dozen hashes are needed even for large files (reducing memory usage compared to a fixed hash block size).<p>link: <a href="https:&#x2F;&#x2F;github.com&#x2F;mixu&#x2F;file-dedupe" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mixu&#x2F;file-dedupe</a>