Rev | Line | |
---|
[5eea6d8] | 1 | #! /bin/sh |
---|
| 2 | |
---|
| 3 | if [ $# -lt 2 ]; then |
---|
| 4 | echo "Usage: $0 directory1 directory2" |
---|
| 5 | exit 1 |
---|
| 6 | fi |
---|
[22a2ffd] | 7 | if [ $# -eq 3 ]; then |
---|
| 8 | [ -d "$1/$3" ] && [ -d "$2/$3" ] && |
---|
| 9 | exit |
---|
| 10 | [ ! -e "$1/$3" ] && [ ! -e "$2/$3" ] && |
---|
| 11 | echo "$0: something wrong abount '$3'" >&2 && exit |
---|
| 12 | [ -e "$1/$3" ] && [ ! -e "$2/$3" ] && |
---|
| 13 | echo "Only in '$1': '$3'" >&2 && exit |
---|
| 14 | [ ! -e "$1/$3" ] && [ -e "$2/$3" ] && |
---|
| 15 | echo "Only in '$2': '$3'" >&2 && exit |
---|
| 16 | [ -f "$1/$3" ] && [ -d "$2/$3" ] && |
---|
[1be8507] | 17 | echo "'$1/$3' is a regular file but '$2/$3' is a directory" >&2 && exit |
---|
[22a2ffd] | 18 | [ -d "$1/$3" ] && [ -f "$2/$3" ] && |
---|
[1be8507] | 19 | echo "'$1/$3' is a directory but '$2/$3' is a regular file" >&2 && exit |
---|
[22a2ffd] | 20 | |
---|
| 21 | cmp -s "$1/$3" "$2/$3" || echo "$1/$3" "$2/$3" are differ >&2 |
---|
| 22 | exit |
---|
| 23 | fi |
---|
[5eea6d8] | 24 | if [ -d "$1" -a -d "$2" ]; then |
---|
| 25 | echo "$0: start comparing '$1' and '$2'" >&2 |
---|
| 26 | fi |
---|
| 27 | |
---|
| 28 | list=`mktemp --tmpdir cmpdir.list.XXXXXXXXXX` || exit 1 |
---|
| 29 | tmp=`mktemp --tmpdir cmpdir.tmp.XXXXXXXXXX` || exit 1 |
---|
| 30 | trap "rm -- '$list' '$tmp'" EXIT |
---|
| 31 | |
---|
| 32 | wc=$PWD |
---|
| 33 | cd "$1" |
---|
[22a2ffd] | 34 | find -print0 >> "$tmp" |
---|
[5eea6d8] | 35 | cd $wc |
---|
| 36 | |
---|
| 37 | cd "$2" |
---|
[22a2ffd] | 38 | find -print0 >> "$tmp" |
---|
[5eea6d8] | 39 | cd $wc |
---|
| 40 | |
---|
| 41 | sort -z "$tmp" | uniq -z > "$list" |
---|
| 42 | |
---|
| 43 | |
---|
[22a2ffd] | 44 | xargs -a "$list" -0 -n 1 -I entry $0 "$1" "$2" "entry" |
---|
Note: See
TracBrowser
for help on using the repository browser.