3 # compares the files and directory names in two different top-level directories
4 # and prints a report of the differences.
9 if [ -z "$dir1" -o -z "$dir2" ]; then
10 echo This script needs two directory names for which it will create a
11 echo list of differences in the two directory hierarchies.
14 #if [ ! -d "$dir1/" -o ! -d "$dir2/" ]; then
15 # echo The directories to be compared must already exist.
18 if [ "$dir1" == "$dir2" ]; then
19 echo "The two directories are the exact same folder name. So that's silly."
23 source "$FEISTY_MEOW_SCRIPTS/core/launch_feisty_meow.sh"
25 out1="$(mktemp "$TMP/compare_dirs_output.XXXXXX")"
26 out2="$(mktemp "$TMP/compare_dirs_output.XXXXXX")"
29 #hmmm: need error checking in here!!!!
32 # host processing on first dir.
33 if [[ $dir1 == *":"* ]]; then
36 #echo "got host1 as $host1 and new dir1 as $dir1"
39 # host processing on second dir.
40 if [[ $dir2 == *":"* ]]; then
43 #echo "got host2 as $host2 and new dir2 as $dir2"
46 if [ -z "$host1" ]; then
47 # fully local compare location for first dir.
48 pushd "$dir1" &>/dev/null
49 exit_on_error "compare_dirs: seeking directory $dir1"
53 # remote compare location for first dir.
54 ssh "$host1" "cd \"$dir1\" && find ." >"$out1"
55 exit_on_error "compare_dirs: listing remote directory $dir1"
58 # sort the output from listing the first directory.
59 sort "$out1" >"$out1".sort
61 if [ -z "$host2" ]; then
62 # fully local compare location for second dir.
63 pushd "$dir2" &>/dev/null
64 exit_on_error "compare_dirs: seeking directory $dir2"
68 # remote compare location for second dir.
69 ssh "$host2" "cd \"$dir2\" && find ." >"$out2"
70 exit_on_error "compare_dirs: listing remote directory $dir2"
73 # sort the output from listing the second directory.
74 sort "$out2" >"$out2".sort
76 # compare the two sorted output files to show the missing files on each side.
77 diff "$out1".sort "$out2".sort
79 # clean up our output files.
80 rm "$out1" "$out1".sort "$out2" "$out2".sort