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".
7 exemplar_dir="$1"; shift
10 # make sure they gave us a good directory to start with.
11 if [ -z "$exemplar_dir" ]; then
15 echo "This program needs at least one directory parameter. The files in the"
16 echo "current directory will be removed if a file in the specified directory"
17 echo "already exists. So... the current directory is the less important one"
18 echo "and is presumed to have duplicates AND the directory given as parameter"
19 echo "is considered important and has the best versions of the files."
20 echo "If there is an optional second parameter, then that is used as the"
21 echo "\"current\" directory where we start from; it will be the less important"
22 echo "directory and will have its entries cleaned if they're duplicates."
26 # check to make sure they gave us a good directory.
27 if [ ! -z "$whack_dir" -a ! -d "$whack_dir" ]; then
28 echo "the directory $whack_dir does not exist."
32 # test the tasty remote location with the better contents.
33 pushd "$exemplar_dir" &>/dev/null
35 # an error getting to this directory means its no good for us.
36 echo "the directory $exemplar_dir is inaccessible."
39 the_good_place="$(pwd)"
42 if [ ! -z "$whack_dir" ]; then
43 # use the directory as our "current" location.
44 pushd "$whack_dir" &>/dev/null
49 #echo "currdir=$current_dir gooddir=$the_good_place"
51 if [ "$current_dir" == "$the_good_place" ]; then
52 # this is not good; they're the same location.
53 echo "the request would whack all the files in the current directory; ignoring."
57 # do the real work now...
59 if [ -f "$exemplar_dir/$i" ]; then
65 if [ ! -z "$whack_dir" ]; then