annotate scripts/duplicates.sh @ 97:34f11b2a1178

Script to extract duplicates directly to the commandline.
author Tom Fredrik Blenning Klaussen <bfg@bfgconsult.no>
date Thu, 13 Feb 2014 14:51:06 +0100
parents
children 6b997f4f7e19
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
97
34f11b2a1178 Script to extract duplicates directly to the commandline.
Tom Fredrik Blenning Klaussen <bfg@bfgconsult.no>
parents:
diff changeset
1 #!/bin/bash
34f11b2a1178 Script to extract duplicates directly to the commandline.
Tom Fredrik Blenning Klaussen <bfg@bfgconsult.no>
parents:
diff changeset
2
34f11b2a1178 Script to extract duplicates directly to the commandline.
Tom Fredrik Blenning Klaussen <bfg@bfgconsult.no>
parents:
diff changeset
3 PREFIX=$1
34f11b2a1178 Script to extract duplicates directly to the commandline.
Tom Fredrik Blenning Klaussen <bfg@bfgconsult.no>
parents:
diff changeset
4
34f11b2a1178 Script to extract duplicates directly to the commandline.
Tom Fredrik Blenning Klaussen <bfg@bfgconsult.no>
parents:
diff changeset
5 if [ -n "$PREFIX" ]
34f11b2a1178 Script to extract duplicates directly to the commandline.
Tom Fredrik Blenning Klaussen <bfg@bfgconsult.no>
parents:
diff changeset
6 then
34f11b2a1178 Script to extract duplicates directly to the commandline.
Tom Fredrik Blenning Klaussen <bfg@bfgconsult.no>
parents:
diff changeset
7 PREFIX="WHERE path LIKE '${PREFIX}%'"
34f11b2a1178 Script to extract duplicates directly to the commandline.
Tom Fredrik Blenning Klaussen <bfg@bfgconsult.no>
parents:
diff changeset
8 fi
34f11b2a1178 Script to extract duplicates directly to the commandline.
Tom Fredrik Blenning Klaussen <bfg@bfgconsult.no>
parents:
diff changeset
9
34f11b2a1178 Script to extract duplicates directly to the commandline.
Tom Fredrik Blenning Klaussen <bfg@bfgconsult.no>
parents:
diff changeset
10 sqlite3 ~/.DeDupe.sqlite "SELECT hex(checksum),path FROM (SELECT * FROM files WHERE checksum IN (SELECT checksum FROM (SELECT checksum, COUNT(*) as num FROM files ${PREFIX} GROUP BY checksum) WHERE num >= 2)) ${PREFIX} ORDER BY size;"