Skip to Main Content
Linux Shell Scripting Essentials
book

Linux Shell Scripting Essentials

by Sinny Kumari
November 2015
Beginner content levelBeginner
282 pages
5h 5m
English
Packt Publishing
Content preview from Linux Shell Scripting Essentials

Sorting and finding unique text

Shell provides different ways to sort the input text using the sort command. It's also possible to remove repeated lines from sorted/unsorted input text using the uniq command. The input text to sort and uniq commands can be given from a file, or redirected from another command.

Sorting an input text

The lines in the input text are sorted in the following order:

  • Numbers from 0 to 9
  • Uppercase letters from A to Z
  • Lowercase letters from a to z

The syntax will be as follows:

sort [OPTION] [FILE …]

Single or multiple input files can be provided to sort for sorting.

The sort command takes multiple options to provide flexibility in sorting. The popular and important OPTION to sort have been discussed in the following table:

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Linux Shell Scripting

Learning Linux Shell Scripting

Ganesh Sanjiv Naik

Publisher Resources

ISBN: 9781785284441Supplemental Content