You have to `sort` before you `uniq`: $ grep "<s id" txtgmmden_en.txt | sort | uniq -d <s id="282"> So it turns out there is a duplicate after all :) Best, David