#! /bin/bash CLEANUP=1 ## Delete temp files on exit, unless 'k' switch if give on command line. BASEDIR=$PWD #Parse command line for options for a in 1 $*; do if [ $a = -v ] || [ $a = -V ]; then VERBOSE=1; else VERBOSE=0; fi; done for b in 1 $*; do if [ $b = -h ] || [ $b = -H ]; then HELP=1; else HELP=0; fi; done for c in 1 $*; do if [ $c = -O ]; then OUT2FILE="1"; else OUT2FILE="0"; fi; done for d in 1 $*; do if [ $d = -o ]; then OUT2FILE="2"; fi; done for e in 1 $*; do if [ $e = -k ] || [ $b = -K ]; then CLEANUP=0; fi; done help () { cat </dev/null | sed s#./##) if [ -L "$b" ]; then continue elif [ -f "$b" ]; then echo -n "$PWD/$b:" >> $BASEDIR/dupelist.tmp md5sum "$b" >> $BASEDIR/dupelist.tmp elif [ -d "$b" ]; then cd "$b" seek cd .. fi fi done } parse() { cut -d ":" -f 2 dupelist.tmp | cut -b -33 | sort > sums.tmp if [ $OUT2FILE = 1 ] then rm DuplicateFiles.txt 2>/dev/null for c in $(uniq -d sums.tmp) do echo | tee -a DuplicateFiles.txt grep $c dupelist.tmp | cut -d ":" -f 1 | tee -a DuplicateFiles.txt echo | tee -a DuplicateFiles.txt done elif [ $OUT2FILE = 2 ] then rm DuplicateFiles.txt 2>/dev/null for c in $(uniq -d sums.tmp) do echo >>DuplicateFiles.txt grep $c dupelist.tmp | cut -d ":" -f 1 >>DuplicateFiles.txt echo >>DuplicateFiles.txt done elif [ $OUT2FILE = 0 ] then for c in $(uniq -d sums.tmp) do echo grep $c dupelist.tmp | cut -d ":" -f 1 echo done fi } if [[ $HELP = 1 ]]; then help; fi seek parse if [[ $CLEANUP = 1 ]]; then rm dupelist.tmp sums.tmp; fi