read the man file on uniq, the -d option only prints duplicate lines.
sort textfile.txt|uniq -d
should get you what you want and it's a little more elegant.
Originally Posted by titopoquito
You could use sort/uniq/diff to find those lines. There are probably simpler solutions
sort textfile.txt > sorted.txt
sort textfile.txt | uniq > sorted-and-uniq.txt
diff sorted.txt sorted-and-uniq.txt
will give you all lines that are duplicates.