Uniq command in Linux not working properly

1.6k Views Asked by At

I am new to Linux and while I was trying to understand uinq command I encountered this problem I created a file hello2 using cat command and entered these text in it

hello 

hello   
google   
hello 

then I ran this command

sort hello2 | uniq 

the output

google  
hello  
hello 

so far what I understood about uniq command on that basis the output should be different

google  
hello

can someone please understand why this happened?

1

There are 1 best solutions below

0
On

There might be a space in one of the repeated words so the other hello is still outputted.

You can check on this article for a more detailed information regarding uniq.