Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

how can I list the identical words from below file using shell script ?

list.txt

LT
R
LT
MRTD
LT
MK
RR
RR

example result :

LT
R
MRTD
MK
RR
share|improve this question

closed as off topic by womble, Shane Madden, voretaq7 Nov 14 '12 at 2:43

Questions on Server Fault are expected to relate to server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

1  
Your example result doesn't make sense R,MRTD and MK aren't duplicated ? Your Example result shows the unique 'words'. Please clarify your requirements. –  Iain Jul 18 '12 at 7:04

2 Answers 2

up vote 0 down vote accepted

Use sort, and uniq like this:

 cat list.txt | sort | uniq
share|improve this answer
1  
You don't need cat. sort list.txt | uniq works. –  Iain Jul 18 '12 at 7:05
2  
Gratuitous use of cat is gratuitous. –  womble Jul 18 '12 at 7:14
    
You are right. My mistake. –  Stone Jul 18 '12 at 8:04

sort also has the --unique option:

$ sort -u list.txt
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.