May 2012

How do you remove the duplicate items in the file in linux?

For example file items.txt have duplicate items
printer
paper
Ink
paper
xerox
Ink
scanner
printer

To remove duplicate from this file

you can use uniq it will remove duplicates and display.

if you want to write the unique item into file
uniq uniq_itemes.txt

Note: This uniq program makes every line as unique, not the words