3 # whacks the files in the current directory which are duplicates of the
4 # files in the directory passed as a parameter.
5 # if there is a second parameter, then it is used as the "current directory"
6 # and it will be the target of any deletions.
8 exemplar_dir="$1"; shift
11 # make sure they gave us a good directory to start with.
12 if [ -z "$exemplar_dir" ]; then
13 echo "$(basename $0 .sh): This program needs at least one directory parameter."
14 echo "The files in the current directory will be removed if a file in the specified directory"
15 echo "already exists. So... the current directory is the less important one and is presumed"
16 echo "to have duplicates AND the directory given as parameter is considered important and has"
17 echo "the best versions of the files."
18 echo "If there is an optional second parameter, then that is used as the"
19 echo "\"current\" directory where we start from; it will be the less important"
20 echo "directory and will have its entries cleaned if they're duplicates."
24 # check to make sure they gave us a good directory.
25 if [ ! -z "$whack_dir" -a ! -d "$whack_dir" ]; then
26 echo "the directory $whack_dir does not exist."
30 # test the tasty remote location with the better contents.
31 pushd "$exemplar_dir" &>/dev/null
33 # an error getting to this directory means its no good for us.
34 echo "the directory $exemplar_dir is inaccessible."
37 the_good_place="$(pwd)"
40 if [ ! -z "$whack_dir" ]; then
41 # use the directory as our "current" location.
42 pushd "$whack_dir" &>/dev/null
47 #echo "currdir=$current_dir gooddir=$the_good_place"
49 if [ "$current_dir" == "$the_good_place" ]; then
50 # this is not good; they're the same location.
51 echo "the request would whack all the files in the current directory; ignoring."
55 # do the real work now...
57 if [ -f "$exemplar_dir/$i" ]; then
63 if [ ! -z "$whack_dir" ]; then