bin/fsdiff.sh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
#!/bin/sh # Note: this is designed to also work across machines (i.e. remotely). For # local-only directory comparisons where permissions, mod-times, etc... can be # ignored, you can actually do this with just 'diff': # $ diff --recursive --brief DIR1 DIR2 if [ "$#" != 2 ]; then echo "usage: fsdiff.sh [DIR1] [DIR2]" echo "Compare files from directory DIR2 to directory DIR1" exit 1 fi # Note: '--itemize-changes' is a useful option sometimes. # symmetrical diff (compare both directories to one another; differences in # DIR2 will be preceeded by 'deleted') rsync_flags="--recursive --links --verbose --checksum --delete --dry-run" # directional diff (compare DIR2 to contents of DIR1) #rsync_flags="--recursive --links --verbose --checksum --dry-run" #echo "By default, prints files which are different in ${1}" #echo "'deleting' means the file is different/new in ${2} (not present in ${1})" rsync $rsync_flags "${1}/" "${2}" |