Adminbuntu

Everything for the Ubuntu Server Administrator

User Tools

Site Tools


Sidebar

Server Administration


Server Applications


At the Command Line


Elsewhere


Copyright 2013 Applied Conscious Technologies, LLC

Terms of Agreement

Contact


submit to reddit

sorting

At the Command Line

Sorting

Sorting the output of other commands often improves the ability to use the resulting data.

sort man page: http://manpages.ubuntu.com/manpages/precise/man1/sort.1.html

uniq man page: http://manpages.ubuntu.com/manpages/precise/man1/uniq.1.html

join man page: http://manpages.ubuntu.com/manpages/precise/man1/join.1.html


Union of unsorted files

sort file1 file2 | uniq

Intersection of unsorted files

sort file1 file2 | uniq -d

Difference of unsorted files

sort file1 file1 file2 | uniq -u

Symmetric Difference of unsorted files

sort file1 file2 | uniq -u

Union of sorted files

join -a1 -a2 file1 file2

Intersection of sorted files

join file1 file2

Difference of sorted files

join -v2 file1 file2

Symmetric Difference of sorted files

join -v1 -v2 file1 file2

sorting.txt · Last modified: 2015/05/31 21:20 (external edit)