> ## Content Index
> Fetch the complete content index at: https://kudithipudi.org/llms.txt
> Use this file to discover other available public pages before exploring further.

# Simple script to compare files in two directories..
- URL: https://kudithipudi.org/simple-script-to-compare-files-in-two-directories/
- Published: 2008-02-29T02:35:02.000Z
- Updated: 2008-02-29T02:35:02.000Z
- Description: Here’s a small script to compare the files in two different directories on a Linux machine. The script uses MD5 checksum to compare the files. #\!/bin/bash...
- Author: admin
- Tags: Linux, Programming, Technology, Uncategorized, #wp, #wp-post, #Import 2026-08-23 02:32

Here’s a small script to compare the files in two different directories on a Linux machine. The script uses MD5 checksum to compare the files.

#\\!/bin/bash  
prefix1=â€œ/usr/directory1â€³ # First directory without trailing /  
prefix2=â€œ/usr/directory2â€³ # Second directory without trailing /  
find \\-L â€œ$prefix1â€³ \\-type f \\| while read filename; do  
name=â€œ${filename#$prefix1\*}â€  
sum1=â€œ$(md5sum \\-b â€$prefix1$nameâ€œ)â€  
sum2=â€œ$(md5sum \\-b â€$prefix2$nameâ€œ)â€  
if \\\[ â€œ${sum1% \\\*}â€ = â€œ${sum2% \\\*}â€ \\\]; then  
echo â€œok: $prefix1$nameâ€  
else  
echo â€œnot ok: $prefix1$nameâ€  
fi  
done