Number of non repeating lines - unique count

john blackwood picture john blackwood · May 2, 2013 · Viewed 59.4k times · Source

Here is my problem: Any number of lines of text is given from standard input. Output: number of non repeating lines

INPUT:

She is wearing black shoes.
My name is Johny.
I hate mondays.
My name is Johny.
I don't understand you.
She is wearing black shoes.

OUTPUT:

2

Answer

Ding picture Ding · May 2, 2013

You could try using uniq man uniq and do the following

sort file | uniq -u | wc -l