File: dircompare

package info (click to toggle)
afio 2.5-5
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 616 kB
  • ctags: 475
  • sloc: ansic: 4,678; sh: 535; makefile: 127; awk: 19
file content (23 lines) | stat: -rwxr-xr-x 701 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

#the way of calling this script is strange to preserve compatibility
#with the horrid approximation of a bash that I found on a freebsd system.

#dircompare compares contents of dirs $d1 and $d2 carefully
#prints problems found to stdout
#exits with 1 on error.

fail=0;

#compare file contents
find $d1 -type f | $AWK '{ n=$0; gsub("^"d1,d2,n); print "if ! cmp \""$0"\" \""n"\"; then fail=1; fi"; }' d1=$d1 d2=$d2 - >dircompare.tmp

#compare file stat blocks
source dircompare.tmp

find $d1 | $AWK '{ n=$0; gsub("^"d1,d2,n); print "if ! ./cmpstat \""$0"\" \""n"\" "cmpflag"; then fail=1; fi"; }' d1=$d1 d2=$d2 cmpflag=$cmpflag - >dircompare.tmp

source dircompare.tmp

rm dircompare.tmp

exit $fail