# dups.ksh
# This displays a report listing files that have the same name in the folders
# at or below the point from which it is run (default) or from the directory
# given as a command line argument (and the number of occurances of said files).
directory=${1:-.}
if [ ! -d $directory ]; then
echo $directory is not a valid directory!
return 1
fi
find $directory \( \
-name '*.rc' -o \
-name '*.c' -o \
-name '*.cc' -o \
-name '*.cpp' -o \
-name '*.h' -o \
-name '*.d' -o \
-name '*.y' -o \
-name '*.l' -o \
-name '*.inl' -o \
-name '*.ad' -o \
-name '*.cf' -o \
-name '*.java' -o \
-name '*.rsl' \) \
-print |
awk 'BEGIN {FS="/"}
{fs[tolower($NF)]++}
END {for (f in fs) if (1 < fs[f]) print f " (" fs[f] ")"}' |
sort -f