sort
Sort lines and drop duplicates
What it does
sort prints the lines of a file in alphabetical order. -n sorts them as numbers (otherwise 10 comes before 9), -r in reverse.
uniq removes repeated lines, but only adjacent ones, so it goes after sort: sort names.txt | uniq. sort -u does the same. And sort | uniq -c counts how many times each line appears.
Syntax
sort <file>
sort -n <file>
sort <file> | uniqExamples
Sort the lines of names.txt and remove duplicates
sort names.txt | uniqsame as:
sort -u names.txtsort names.txt— sort lines| uniq— drop adjacent duplicates