Question

i have a data.txt file as below

1
1
100
100
1
1
1

when i tried,

more 'data.txt|uniq' 

I get the uniq value of multiple occurrences consecutively

1
100
1

Is there a way, i can get the result as

1
100

Thanks in advance

Was it helpful?

Solution

try executing

$ sort -u data.txt

Description:

according to manpage of uniq

Note: 'uniq' does not detect repeated lines unless they are adjacent. You may want to sort the input first, or use 'sort -u' without 'uniq'.

you can read manpage by executing

$ man uniq

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top