1

From the document said that the option --count going to

prefix lines by the number of occurrences

but after I do some test it seems doesn't work.

$ echo -e "a\na\b\nc" |uniq --count
      1 a
      1 a
      1 c

Should the line 'a' occurs 2 times?

Smile.Hunter
  • 8,705

1 Answers1

3

If I understand what you are trying to do, there is a typo in your original string that is confusing uniq (it thinks there are 1+1+1 lines instead of 2+1+1). There is an "n" missing.

echo -e "a\na\nb\nc" |uniq --count
  2 a
  1 b
  1 c

I guess this is the result you were expecting, as it is coherent with the man page.

sergut
  • 300