1 #!/bin/sh 2 # Does the same as the python version only slower. 3 # Systems without python can therefore use this. 4 5 suffix=.fixdup.$$ 6 7 symlink=0 8 link=1 9 dryRun=0 10 if [ "$#" = "1" ]; then 11 if [ "$1" = "del" ]; then 12 link=0 13 elif [ "$1" = "tdel" ]; then 14 link=0 15 dryRun=1 16 elif [ "$1" = "tmerge" ]; then 17 dryRun=1 18 elif [ "$1" = "symlink" ]; then 19 symlink=1 20 elif [ "$1" = "tsymlink" ]; then 21 dryRun=1 22 symlink=1 23 fi 24 fi 25 26 keepfile='nextfile' 27 while read file; do 28 if [ -z "$file" ]; then 29 keepfile="nextfile" 30 elif [ "nextfile" = "$keepfile" ]; then 31 keepfile="$file" 32 if [ "$dryRun" = "1" ]; then 33 printf "\n\nkeeping: $keepfile\n" 34 if [ "$symlink" = "1" ]; then 35 printf "symlinking: " 36 elif [ "$link" = "1" ]; then 37 printf "hardlinking: " 38 else 39 printf "deleting: " 40 fi 41 fi 42 else 43 if [ "$dryRun" = "1" ]; then 44 printf "$file " 45 else 46 if [ "$link" = "1" ]; then 47 { 48 test "$symlink" = 0 && 49 ln -f -b --suffix="$suffix" -- "$keepfile" "$file" 2>/dev/null; 50 } || 51 ln -sf -b --suffix="$suffix" -- "$keepfile" "$file" 52 rm -f "$file$suffix" 53 else 54 rm -f "$file" 55 fi 56 fi 57 fi 58 done 59 if [ "$dryRun" = "1" ] && [ "$keepfile" != "nextfile" ]; then 60 echo 61 fi