Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Number of non repeating lines - unique count

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 
like image 726
john blackwood Avatar asked May 01 '13 22:05

john blackwood


People also ask

How do you count unique values without duplicates?

You can use the combination of the SUM and COUNTIF functions to count unique values in Excel. The syntax for this combined formula is = SUM(IF(1/COUNTIF(data, data)=1,1,0)). Here the COUNTIF formula counts the number of times each value in the range appears.

What is unique count?

The Unique Count measure gives the number of unique (distinct) values in a column. Empty values are not counted. In the table below, column A has a unique count of two and column B has a unique count of three.

How do I count unique values in multiple conditions in Excel?

The trick is to "feed" the entire range to UNIQUE so that it finds the unique combinations of values in multiple columns. After that, you simply enclose the formula in the ROWS function to calculate the number of rows.


1 Answers

You could try using uniq man uniq and do the following

sort file | uniq -u | wc -l 
like image 178
Ding Avatar answered Oct 12 '22 01:10

Ding