[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Uniq is not unique ?



Bhasker C V wrote:
> Hi,
>
>
>  
>  For fairly large file 100K+ lines
>  uniq command does not filter the repetitive lines.
>
>  Am I doing anything wrong on the usage ? 
>
>  For eg:-
>
>  I had run this script in my home dir
>
>  find . -name \* -type f -exec basename {} \; | uniq
>   or send the output to a file and then run uniq on the file 
>
>  Both cases, the o/p shows repeated lines
>From man uniq(1):

DESCRIPTION
       Discard  all but one of successive identical lines from INPUT (or
stan-
       dard input), writing to OUTPUT (or standard output).

And, later:

       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’.

Since find will output the names in no particular order, you'll have to
sort first.


-- 
America works less, when you say "Union Yes!"

Eduardo M KALINOWSKI
ekalin@gmail.com
http://move.to/hpkb


Reply to: