O'Reilly logo

Linux Shell Scripting Cookbook by Sarath Lakshman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Sorting, unique and duplicates

Sorting is a common task that we always encounter with text files. Hence, in text processing tasks, sort is very useful. sort commands help us to perform sort operations over text files and stdin. Most often, it can also be coupled with many other commands to produce the required output. uniq is another command that is often used along with a sort command. It helps to extract unique lines from a text or stdin. sort and uniq can be coupled to find duplicates. This recipe illustrates most of the use cases with sort and uniq commands.

Getting ready

The sort command accepts input as filenames as well as from stdin (Standard input) and outputs the result by writing into stdout. The uniq command follows the same sequence ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required