Last active
September 11, 2017 23:12
-
-
Save arcticmouse/44227a8a53197a5e89b44c55c5021d47 to your computer and use it in GitHub Desktop.
Recursively search directory in terminal for duplicate files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
line 1 - prints count + file name
line 5 - prints count, file name / where files are listed