Skip to content

Instantly share code, notes, and snippets.

@arcticmouse
Last active September 11, 2017 23:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arcticmouse/44227a8a53197a5e89b44c55c5021d47 to your computer and use it in GitHub Desktop.
Save arcticmouse/44227a8a53197a5e89b44c55c5021d47 to your computer and use it in GitHub Desktop.
Recursively search directory in terminal for duplicate files
find . -type f | sed 's/^.*\/\([^/]*\)$/\1/' | sort | uniq -c | grep -v '^ 1'
IFS=$'\n'; for f in `find . -type f | sed 's/^.*\/\([^/]*\)$/\1/' | sort | uniq -c | grep -v '^ 1'`; do echo $f; t=`echo "$f" | awk '{print $2}'`; find . -name $t; echo $'\n'; done
IFS=$'\n'
dupes=`find . -type f |
sed 's/^.*\/\([^/]*\)$/\1/' |
sort |
uniq -c |
grep -v '^ 1'`
for f in $dupes; do
echo $f;
t=`echo "$f" | awk '{print $2}'`;
find . -name $t;
echo $'\n';
done
@arcticmouse
Copy link
Author

line 1 - prints count + file name

line 5 - prints count, file name / where files are listed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment