Skip to content

Instantly share code, notes, and snippets.

@nahurst
Created November 14, 2015 03:35
Show Gist options
  • Save nahurst/63a691c29111dfd2d82e to your computer and use it in GitHub Desktop.
Save nahurst/63a691c29111dfd2d82e to your computer and use it in GitHub Desktop.
Find duplicate file names on OS X
# because we don't have findsn with fslint, we need to do it ourselves
# find . -type f -exec basename {} \; | \ # get the name of the file. could be substituted to do hashes here
# sort | \ # prep for counting
# uniq -c | \ # count occurences
# grep -v "^[ \t]*1 " | \ # mind the formatting
# awk '{print $2}' | \ # get only the file names, not the counts
# xargs -I {} find . -name '{}*' # find the location of the duplicates
find . -type f -exec basename {} \; | \
sort | \
uniq -c | \
grep -v "^[ \t]*1 " | \
awk '{print $2}' | \
xargs -I {} find . -name '{}*'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment