Duplicate lines in the file

Hi,

I have a file with duplicate lines in it. I want to keep only the duplicate lines and delete the non duplicates. Can some one please help me?

Regards
Narayana Gupta

IF the file is already sorted, then

uniq -d filename

otherwise

sort filename | uniq -d

awk '{a[$0]++;} END {for (i in a) {if (a [i]> 1) print i;} }' filename

Thanks Ranj, It worked.

Regards
Narayana Gupta