I need to remove files with identical size but not identical content on Linux, that is why fdupes is not an option.
I tried the following command, however it did not remove all files with identical sizes (no idea why)
last=-1; find . -type f -name '*.png' -printf '%f\0' | sort -nz | while read -d '' i; do s=$(stat -c '%s' "$i"); [[ $s = $last ]] && rm "$i"; last=$s; done
Any ideas? What did I wrong?
EDIT: I made a mistake in the initial post. I need to keep one file from the given size, for example:
1.png # 23,5 Kb
2.png # 24,6 Kb
4.png # 24,6 Kb > remove
8.png # 24,6 Kb > remove
16.png # 23,5 Kb
Basically I want to remove duplicates, but not by checksum and by size only.